Пример #1
0
 @Override
 public void onClick(View v) {
   Intent intent;
   switch (v.getId()) {
     case R.id.btn_login:
       Utils.alertToast(getBaseContext(), tag, "开启Service");
       intent = new Intent(this, ChatService.class);
       startService(intent);
       Message msg = Message.obtain(null, Common.LOGIN);
       Bundle b = new Bundle();
       b.putInt("account", Integer.parseInt(et_account.getText().toString()));
       b.putString("password", et_password.getText().toString());
       msg.setData(b);
       try {
         rMessenger.send(msg);
       } catch (RemoteException e) {
         e.printStackTrace();
       }
       break;
     case R.id.btn_regist:
       Utils.alertToast(getBaseContext(), tag, "开启Service");
       intent = new Intent(this, ChatService.class);
       startService(intent);
       Message test_message = Message.obtain(null, PackageType.TEST);
       try {
         rMessenger.send(test_message);
       } catch (RemoteException e) {
         e.printStackTrace();
       }
       break;
   }
 }
Пример #2
0
 @Override
 public void handleMessage(Message msg) {
   super.handleMessage(msg);
   switch (msg.what) {
     case Common.LOGIN_SUCCESS:
       gotoFriendListActivity();
       break;
     default:
       Utils.alertToast(getBaseContext(), tag, "接收到未定义事件码:" + msg.what);
       break;
   }
 }