How do you prevent an Android Wear activity from having multiple instances?

时光毁灭记忆、已成空白 提交于 2019-12-04 12:31:43

问题


Sometimes, most of the time when my LG G watch closes the app automatically by going to sleep/dim mode, if I open the app again by going to the start menu there are two instances of the activity opened (when I slide one off the previous one is underneath).

This never happens in a phone, is this how activities work in Android Wear? Should I "finish()" them in onPause()?

Thanks.


回答1:


Have you looked at the android:launchMode attribute in the AndroidManifest.xml for the activity?

perhaps android:launchMode="singleInstance" will help you out.

http://developer.android.com/guide/topics/manifest/activity-element.html#lmode



来源:https://stackoverflow.com/questions/25310832/how-do-you-prevent-an-android-wear-activity-from-having-multiple-instances

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