My question is that I have two types of activity: activity A and activity B. Activity A is the main activity, activity B is available only by touching the notification.
I need to be able to touch the notification that action B will open. After the user completes action B, they can click the back button or complete the “Activity B.” When action "B" closes, action "A" should be shown. I am currently closing Activity A (which closes the entire application) and receiving a push notification. I select the push notification that Activity B opens. When I close Activity B, Activity A does not appear and the entire application closes. I want Activity A to be after Activity B.
I am using Parse SDK notifications. In my regular ParsePushBroadcastReceiver, I have the following code
public class MyReceiver extends ParsePushBroadcastReceiver
{
@Override
public void onPushOpen(Context context, Intent intent)
{
Intent i = new Intent(context, NotificationActivity.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
I pointed it in the Android manifest. My manifest notification activity
<activity
android:name=".NotificationActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan"
android:screenOrientation="portrait"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
</activity>
In my notification activity, I have the following code in onBackPressed
public class NotificationActivity extends ActionBarActivity
{...
@Override
public void onBackPressed()
{
if(NavUtils.getParentActivityName(this) != null)
{
Log.d(Constants.NAVIGATION_DEBUG, "Get Parent Activity NOT NULL");
NavUtils.navigateUpFromSameTask(this);
}
else
{
Log.d(Constants.NAVIGATION_DEBUG, "Get Parent Activity NULL");
super.onBackPressed();
}
}
...}
, , , Activity A, . . , Activity A , , . !