带有TaskStackBuilder.addParentStack的Android parentActivityName停止在API 21(Lollipop)上工作 [英] Android parentActivityName with TaskStackBuilder.addParentStack stopped working on API 21 (Lollipop)
本文介绍了带有TaskStackBuilder.addParentStack的Android parentActivityName停止在API 21(Lollipop)上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从小部件打开应用程序时,我正在使用此代码来设置向后堆栈导航.
I'm using this code to setup back stack navigation when opening the app from a widget.
Intent intent = new Intent(context, ComposeActivity.class);
// Create an Intent to launch ComposeActivity
intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
// Adds the back stack
stackBuilder.addParentStack(ComposeActivity.class);
// Adds the Intent to the top of the stack
stackBuilder.addNextIntent(intent);
// Gets a PendingIntent containing the entire back stack
PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
// Get the layout for the App Widget and attach an on-click listener to the button
RemoteViews recordButtonImageView = new RemoteViews(
context.getPackageName(), R.layout.record_widget
);
recordButtonImageView.setOnClickPendingIntent(
R.id.record_button, pendingIntent
);
这是我的AndroidManifest.xml定义
and this is my AndroidManifest.xml definition
<activity
android:name=".activities.ComposeActivity"
android:label="@string/compose_activity"
android:parentActivityName=".activities.MyFeedActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Holo.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MyFeedActivity"/>
</activity>
对于API 14-20来说效果很好,但对于API 21却没有效果.
it's working great for API 14 - 20 but not for API 21.
我在做什么错了?
推荐答案
我们最近遇到了同样的问题.
We recently came across this very same issue.
这似乎是 com.android.support:support-v4:21.0.+
中的错误.使用最新发布的版本22,即使cangelog中未提及该更改,它也可以再次工作.
This seems to be a bug in com.android.support:support-v4:21.0.+
. Using the recently released version 22 it's working once again, even though the change is not mentioned in the cangelog.
这篇关于带有TaskStackBuilder.addParentStack的Android parentActivityName停止在API 21(Lollipop)上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文