在一个activity中点击注册按钮后向service发送从activity中获得的帐号密码。 public IBinder onBind(Intent intent) { public boolean onUnbind(Intent intent){ public void onRebind(Intent intent){ |
|
40分 |
可以先解除绑定咯
|
可是我已经解除绑定了,这是activity中的部分代码:
public void sign_up_confirm(View view){ edit_name = name.getText().toString(); edit_password = password.getText().toString(); if(edit_name.equals(“”) || edit_password.equals(“”)){ return; } Bundle bl = new Bundle(); bl.putString(“NAME”, edit_name); bl.putString(“PASSWORD”, edit_password); Log.i(“MyActivity”, edit_name); Intent bindIntent = new Intent(); bindIntent.setClass(this,MyService.class); bindIntent.putExtras(bl); bindService(bindIntent, connection, BIND_AUTO_CREATE); UNBIND = true; } public class MyReceiver extends BroadcastReceiver{ public void onReceive(Context context, Intent intent){ Bundle bundle = intent.getExtras(); String Warning = bundle.getString(“warning”); if (Warning.equals(“Sign up faile”)){ UNBIND = false; unbindService(connection); } else if (Warning.equals(“Sign up success”)) { UNBIND = true; } } } |