在我来说,我一直在使用startActivityForResult调用活动B的活性的。TaskStackBuilder与startActivityForResult
活动B是返回数据到活性的因而数据可被存储在我的数据库的形式。
而且,我的应用程序启动一下,当我尝试去从活动B返回到活动A,因为该方法“onActivityResult”永远不会被调用时我的问题时开始活动B的通知。我不能够模拟startActivityForResult()当我创建我TaskStackBuilder:
Intent resultIntent = new Intent(this, activityB.class);
// This ensures that navigating backward from the Activity leads out of your application to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(activityB.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setContentIntent(resultPendingIntent);
最后,我添加了活性B中的父活动在manifest.xml:
<activity
android:name=".activityB"
android:parentActivityName=".activityA"
android:windowSoftInputMode="stateHidden">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activityA"/>
</activity>