Launching an activity from notification
<p>I am trying to launch an activity from the notification.
I have activity A. The activity A is launched from clicking on the notification. Once the activity A is launched, I like to get back to MainActivity upon pressing the phone's back button. To happen like that I implement as follow. The code is implemented in the BroadcastReceiver. I am having the compilation error at this line <code>Intent resultIntent = new Intent(MainActivity.this, theClass);</code> Because MainActivity.this is not valid in the BroadcastReceiver class. How can I make it correct?  </p>

<pre><code>Class theClass = Class.forName("sg.SanThit.TrackMe.NotificationListActivity");
 Intent resultIntent = new Intent(MainActivity.this, theClass);
resultIntent.putExtra("MOBILENUMBER", tel);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(MainActivity.this);
 // Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(theClass);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(
                               0,
                               PendingIntent.FLAG_UPDATE_CURRENT
                           );
mBuilder.setContentIntent(resultPendingIntent);
</code></pre>
