示例#1
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   hideSoftInputView();
   try {
     unregisterReceiver(receiver);
   } catch (Exception e) {
   }
 }
示例#2
0
 @Override
 protected void onResume() {
   super.onResume();
   // 新消息到达,重新刷新界面
   initOrRefresh();
   MyMessageReceiver.ehList.add(this); // 监听推送的消息
   // 有可能锁屏期间,在聊天界面出现通知栏,这时候需要清除通知和清空未读消息数
   BmobNotifyManager.getInstance(this).cancelNotify();
   BmobDB.create(this).resetUnread(targetId);
   // 清空消息未读数-这个要在刷新之后
   MyMessageReceiver.mNewNum = 0;
 }
示例#3
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   manager = BmobChatManager.getInstance(this);
   MsgPagerNum = 0;
   // 组装聊天对象
   targetUser = (BmobChatUser) getIntent().getSerializableExtra("user");
   targetId = targetUser.getObjectId();
   //		BmobLog.i("聊天对象:" + targetUser.getUsername() + ",targetId = "
   //				+ targetId);
   // 注册广播接收器
   initNewMessageBroadCast();
   initView();
 }
示例#4
0
 @Override
 protected void onPause() {
   super.onPause();
   MyMessageReceiver.ehList.remove(this); // 监听推送的消息
   // 停止录音
   if (recordManager.isRecording()) {
     recordManager.cancelRecording();
     layout_record.setVisibility(View.GONE);
   }
   // 停止播放录音
   if (NewRecordPlayClickListener.isPlaying
       && NewRecordPlayClickListener.currentPlayListener != null) {
     NewRecordPlayClickListener.currentPlayListener.stopPlayRecord();
   }
 }
示例#5
0
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
      switch (requestCode) {
        case BmobConstants.REQUESTCODE_TAKE_CAMERA: // 当取到值的时候才上传path路径下的图片到服务器
          Log.i("yuyang", "本地图片的地址:" + localCameraPath);
          sendImageMessage(localCameraPath);
          break;
        case BmobConstants.REQUESTCODE_TAKE_LOCAL:
          if (data != null) {
            Uri selectedImage = data.getData();
            if (selectedImage != null) {
              Cursor cursor = getContentResolver().query(selectedImage, null, null, null, null);
              cursor.moveToFirst();
              int columnIndex = cursor.getColumnIndex("_data");
              String localSelectPath = cursor.getString(columnIndex);
              cursor.close();
              if (localSelectPath == null || localSelectPath.equals("null")) {
                ShowToast("找不到您想要的图片");
                return;
              }
              sendImageMessage(localSelectPath);
            }
          }
          break;
        case BmobConstants.REQUESTCODE_TAKE_LOCATION: // 地理位置
          double latitude = data.getDoubleExtra("x", 0); // 维度
          double longtitude = data.getDoubleExtra("y", 0); // 经度
          String address = data.getStringExtra("address");
          if (address != null && !address.equals("")) {
            sendLocationMessage(address, latitude, longtitude);
          } else {
            ShowToast("无法获取到您的位置信息!");
          }

          break;
      }
    }
  }