コード例 #1
0
 /**
  * Check if NFC adapter is enabled. If not, show the user a dialog and let him choose between
  * "Goto NFC Setting", "Use Editor Only" and "Exit App". Also enable NFC foreground dispatch
  * system.
  *
  * @see Common#enableNfcForegroundDispatch(Activity)
  */
 private void checkNfc() {
   // Check if the NFC hardware is enabled.
   if (Common.getNfcAdapter() != null && !Common.getNfcAdapter().isEnabled()) {
     // NFC is disabled. Show dialog.
     mEnableNfc.show();
     // Disable read/write tag options.
     mReadTag.setEnabled(false);
     mWriteTag.setEnabled(false);
     return;
   } else {
     // NFC is enabled. Hide dialog and enable NFC
     // foreground dispatch.
     if (mOldIntent != getIntent()) {
       int typeCheck = Common.treatAsNewTag(getIntent(), this);
       if (typeCheck == -1 || typeCheck == -2) {
         // Device or tag does not support Mifare Classic.
         // Run the only thing that is possible: The tag info tool.
         Intent i = new Intent(this, TagInfoToolActivity.class);
         startActivity(i);
       }
       mOldIntent = getIntent();
     }
     Common.enableNfcForegroundDispatch(this);
     mEnableNfc.hide();
     mReadTag.setEnabled(true);
     mWriteTag.setEnabled(true);
   }
 }
コード例 #2
0
 @Override
 protected void onPause() {
   MApplication.getInstance().getmNewsLifecycleHandler().onActivityPaused(this);
   ThirdUtils.statisticsInActivityPause(this);
   if (alertDialog != null && alertDialog.isShowing()) {
     alertDialog.hide();
   }
   if (materialDialog != null && materialDialog.isShowing()) {
     materialDialog.hide();
   }
   PreOnPause();
   super.onPause();
 }
コード例 #3
0
  // ------------------------ INTERFACE METHODS ------------------------
  // --------------------- Interface OnClickListener ---------------------
  @Override
  public void onClick(DialogInterface dialog, int which) {
    Intent intent;
    switch (which) {
      case DialogInterface.BUTTON_POSITIVE:
        // Yes button clicked
        intent = new Intent(CallIntent.ACCEPT_CALL);
        intent.putExtra("callId", mCallId);
        LocalBroadcastManager.getInstance(getBaseContext()).sendBroadcast(intent);
        break;

      case DialogInterface.BUTTON_NEGATIVE:
        // No button clicked
        intent = new Intent(CallIntent.REJECT_CALL);
        intent.putExtra("callId", mCallId);
        LocalBroadcastManager.getInstance(getBaseContext()).sendBroadcast(intent);
        break;
    }
    mAlertDialog.hide();
    finish();
  }