Can I override android:noHistory in code?

我与影子孤独终老i 提交于 2021-01-28 05:21:30

问题


I am using an activity from a third-party library that has set android:noHistory to "true". Is it possible for me to override that value in code before I launch the activity?

Is there an opposite of "FLAG_ACTIVITY_NO_HISTORY" flag I could use with the Intent?


回答1:


I am using an activity from a third-party library that has set android:noHistory to "true".

Add an <activity> element to your own app's manifest, with an android:name attribute identifying the activity, and with android:noHistory="false". As part of the manifest merger process, your app's android:noHistory value should override the library's android:noHistory value.

In general, overriding a library's manifest entry is a somewhat risky move, as you could break something that the library depends upon. In this particular case, it should be safe.




回答2:


If set, the new activity is not kept in the history stack. As soon as the user navigates away from it, the activity is finished. This may also be set with the noHistory attribute.

If set, onActivityResult() is never invoked when the current activity starts a new activity which sets a result and finishes.

https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_NO_HISTORY



来源:https://stackoverflow.com/questions/55119387/can-i-override-androidnohistory-in-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!