如何防止 Android Wear 活动有多个实例? [英] How do you prevent an Android Wear activity from having multiple instances?

查看:25
本文介绍了如何防止 Android Wear 活动有多个实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,大多数情况下,当我的 LG G 手表通过进入睡眠/昏暗模式自动关闭应用程序时,如果我通过转到开始菜单再次打开应用程序,则会打开两个活动实例(当我滑动时前一个在下面).

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).

这在手机中从未发生过,Android Wear 中的 Activity 就是这样工作的吗?我应该在 onPause() 中完成()"它们吗?

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

谢谢.

推荐答案

您是否查看了 AndroidManifest.xmlandroid:launchMode 活动的 android:launchMode 属性?

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

也许 android:launchMode="singleInstance" 会帮助你.

http://developer.android.com/guide/主题/清单/活动元素.html#lmode

这篇关于如何防止 Android Wear 活动有多个实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆