而手机被锁定启动外部活动 [英] Start external activity while phone is locked

查看:214
本文介绍了而手机被锁定启动外部活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够启动一个活动,是不是我的应用程序的一部分,而该设备被密码锁定。我怎么能做到这一点,如果它甚至有可能?

I want to be able to start an Activity that is not part of my app while the device is password locked. How could I do this, if it's even possible?

注意:我深知把 getWindow()的addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);在<$ C $在。 C>的onCreate 。这是行不通的,虽然,因为我没有开始自己的活动,而是一个第三方的一个是我的应用程序之外。

Note: I am well aware of putting getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); within the onCreate of my activity. This will not work, though, as I'm not starting my own activity, but a 3rd party one that is outside of my app.

推荐答案

如果你想在推出锁屏的第三方应用程序将无法正常工作。正如你已经注意到自己,你需要设置窗口标志以确保活动得到了锁屏启动,没有办法以确保其他第三方应用程序中的活动也设置相同的标志。

It will not work if you are trying to launch any third party app over lock screen. As you have observed yourself, you need to set the window flag to ensure that activity get launched over lock screen, there is no way to ensure the activity from other third party app are also setting the same flag.

如果你正在建设一个功能包,其中每个功能只不过是一个不同的应用程序,那么你必须确保这些功能的所有入口点都设置这个窗口标志。最好的办法是申报BaseActivity它设置适当的标志上创建和让所有的功能开发团队使用的基类的入口点。

In case you are building a feature bundle where each feature is nothing but a different application then you will have to ensure that all the entry points of those feature do set this window flag. Best thing would be to declare a BaseActivity which sets proper flag on creation and let all the feature dev team use this as base class for entry points.

这篇关于而手机被锁定启动外部活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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