Example #1
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   try {
     if (KeyEvent.KEYCODE_BACK == keyCode) {
       if (mFileTransfer == null
           || !RcsSessionUtil.isAllowedToAbortFileTransferSession(mFileTransfer)) {
         finish();
         return true;
       }
       AlertDialog.Builder builder = new AlertDialog.Builder(this);
       builder.setTitle(R.string.label_confirm_close);
       builder.setPositiveButton(
           R.string.label_ok,
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int which) {
               quitSession();
             }
           });
       builder.setNegativeButton(
           R.string.label_cancel,
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int which) {
               /* Exit activity */
               finish();
             }
           });
       builder.setCancelable(true);
       registerDialog(builder.show());
       return true;
     }
   } catch (RcsServiceException e) {
     showException(e);
   }
   return super.onKeyDown(keyCode, event);
 }
Example #2
0
  private void quitSession() {
    if (LogUtils.isActive) {
      Log.d(LOGTAG, "quitSession");
    }
    try {
      if (mFileTransfer != null
          && RcsSessionUtil.isAllowedToAbortFileTransferSession(mFileTransfer)) {
        mFileTransfer.abortTransfer();
      }
    } catch (RcsServiceException e) {
      showException(e);

    } finally {
      mFileTransfer = null;
      finish();
    }
  }