コード例 #1
0
ファイル: BaseActivity.java プロジェクト: AdAway/AdAway
  /**
   * Handle result from applying when clicked on notification
   * http://stackoverflow.com/questions/1198558
   * /how-to-send-parameters-from-a-notification-click-to-an-activity BaseActivity launchMode is set
   * to SingleTop for this in AndroidManifest
   */
  @Override
  protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Log.d(Constants.TAG, "onNewIntent");

    // if a notification is clicked after applying was done, the following is processed
    Bundle extras = intent.getExtras();
    if (extras != null) {
      if (extras.containsKey(EXTRA_APPLYING_RESULT)) {
        int result = extras.getInt(EXTRA_APPLYING_RESULT);
        Log.d(Constants.TAG, "Result from intent extras: " + result);

        // download failed because of url
        String numberOfSuccessfulDownloads = null;
        if (extras.containsKey(EXTRA_NUMBER_OF_SUCCESSFUL_DOWNLOADS)) {
          numberOfSuccessfulDownloads = extras.getString(EXTRA_NUMBER_OF_SUCCESSFUL_DOWNLOADS);
          Log.d(
              Constants.TAG,
              "Applying information from intent extras: " + numberOfSuccessfulDownloads);
        }

        ResultHelper.showDialogBasedOnResult(mActivity, result, numberOfSuccessfulDownloads);
      }
    }
  }