Note that there are some explanatory texts on larger screens.

plurals
  1. PONotification intent activity
    text
    copied!<p>I got some issue regarding about the notification intent. I have 2 activity (A &amp; B). Activity A is the main activity of my application. The first activity that user will go through. As for activity B is when the user enter by clicking on a button at Activity A.</p> <p>The thing is when I clicked on my notification and it will direct me to Activity B. Then direct me back to Activity A onBackPressed. But when I close the application and open it back through the multi-tasking option, it resume my application at Activity B. I wanted the application to start back at Activity A instead after closing it. </p> <p>The order should be </p> <p><strong>Activity A --> Activity B.</strong> </p> <p><strong>Notification <em>onClick</em> -> Activity B (<em>onBackPressed</em>) -> Activity A --> Close.</strong> </p> <p><strong>Re-open the app / open with multi-tasking feature --> Activity A</strong></p> <p>Please do let me know if there is any other information that I can provide for a proper understanding to my question. </p> <p>GCM_Intent.class</p> <pre><code> Notification note = new Notification(icon, msgTopic ,System.currentTimeMillis()); Intent i=new Intent(this, Activity_B.class); i.putExtra("topicId", topicId); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP| Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi=PendingIntent.getActivity(this, CommunitiesappConstant.NOTIFICATION_ID, i, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT); note.setLatestEventInfo(this, topicName ,msgInfo+message, pi); note.flags |= Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS; note.ledARGB |= 0xff0000ff; note.ledOffMS |= 1000; note.ledOnMS |= 300; mgr.notify(CommunitiesappConstant.NOTIFICATION_ID, note); </code></pre> <p>Activity B.class</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_b); Bundle bundle = getIntent().getExtras(); topicId = bundle.getString("topicId"); } @Override public void onBackPressed() { super.onBackPressed(); Log.e(TAG, "onBackPressed"); Intent i = new Intent(Activity_B.this, Activity_A.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); finish(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload