public boolean onSupportNavigateUp() {
    Intent upIntent = getSupportParentActivityIntent();

    if (upIntent != null) {
      if (supportShouldUpRecreateTask(upIntent)) {
        TaskStackBuilder b = TaskStackBuilder.create(this);
        onCreateSupportNavigateUpTaskStack(b);
        onPrepareSupportNavigateUpTaskStack(b);
        b.startActivities();

        try {
          ActivityCompat.finishAffinity(this);
        } catch (IllegalStateException e) {
          // This can only happen on 4.1+, when we don't have a parent or a result set.
          // In that case we should just finish().
          finish();
        }
      } else {
        // This activity is part of the application's task, so simply
        // navigate up to the hierarchical parent activity.
        supportNavigateUpTo(upIntent);
      }
      return true;
    }
    return false;
  }
예제 #2
0
 private void createBackStack(Intent intent) {
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
     TaskStackBuilder builder = TaskStackBuilder.create(this);
     builder.addNextIntentWithParentStack(intent);
     builder.startActivities();
   } else {
     startActivity(intent);
     finish();
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    TaskStackBuilder builder = TaskStackBuilder.create(this);
    Intent proxyIntent = getIntent();
    if (!proxyIntent.hasExtra(EXTRA_INTENTS)) {
      finish();
      return;
    }

    for (Parcelable parcelable : proxyIntent.getParcelableArrayExtra(EXTRA_INTENTS)) {
      builder.addNextIntent((Intent) parcelable);
    }

    builder.startActivities();
    finish();
  }
  // override the onPushOpen() method to open "ViewBloodRequestActivity" instead of app's launcher
  // activity when user taps on a Notification
  @Override
  protected void onPushOpen(Context context, Intent intent) {

    // since we override onPushOpen() method, we need to track our app's push open event manually
    ParseAnalytics.trackAppOpenedInBackground(intent);

    String targetActivity = null;

    // get the value of key "target" from the JSON data received in Parse Push notification
    try {
      JSONObject pushData = getJSONDataFromIntent(intent);
      targetActivity = pushData.getString("target");
    } catch (JSONException e) {
      Log.e(TAG, "Unexpected JSONException when receiving push data: ", e);
    }

    // get the launcher activity class for the app from ParsePushBroadcastReceiver's getActivity()
    // method
    Class<? extends Activity> cls = getActivity(context, intent);

    Intent activityIntent;
    if (targetActivity != null && !targetActivity.isEmpty()) {
      // send an explicit intent to open ViewBloodRequestActivity on tapping a push notification
      activityIntent = new Intent(context, ViewBloodRequestActivity.class);
      Log.d("notttt - ", "entering if");
    } else {
      // open the launcher activity of the app
      activityIntent = new Intent(context, cls);
      Log.d("notttt - ", "entering else");
    }

    if (Build.VERSION.SDK_INT >= 16) {
      TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
      stackBuilder.addParentStack(cls);
      stackBuilder.addNextIntent(activityIntent);
      stackBuilder.startActivities();
    } else {
      activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      context.startActivity(activityIntent);
    }
  }
 public boolean b() {
   Intent localIntent = getSupportParentActivityIntent();
   if (localIntent != null) {
     if (a(localIntent)) {
       TaskStackBuilder localTaskStackBuilder = TaskStackBuilder.create(this);
       a(localTaskStackBuilder);
       b(localTaskStackBuilder);
       localTaskStackBuilder.startActivities();
     }
     for (; ; ) {
       try {
         ActivityCompat.finishAffinity(this);
         return true;
       } catch (IllegalStateException localIllegalStateException) {
         finish();
         continue;
       }
       b(localIntent);
     }
   }
   return false;
 }