gpt4 book ai didi

android - [android][lock_screen] 来电时解锁待机屏幕

转载 作者:行者123 更新时间:2023-11-29 02:04:37 25 4
gpt4 key购买 nike

我正在编写一个基于 sip 的调用应用程序。当有来电时,它的相应 Activity 将被触发并显示在锁定屏幕下方。但是用户不知道这个电话...锁定屏幕会出现一段时间然后屏幕会关闭...即使电话仍在响起...铃声在整个持续时间内都处于 Activity 状态但屏幕没有' 显示来电 UI。我需要找到一种方法来显示适当的 UI 并在来电的整个过程中保持屏幕打开...

为了在整个来电期间保持屏幕开启,我使用了唤醒锁...但我无法摆脱锁定屏幕...

我研究并发现可以使用 KeygaurdManagerWindowManager.LayoutParams 以及适当的标志,如 FLAG_KEEP_SCREEN_ONFLAG_DISMISS_KEYGAURD , FLAG_SHOW_WHEN_LOCKEDFLAG_TURN_SCREEN_ON 来解锁手机...但是这些在我的情况下不起作用...我在以下链接之一中读到无法解锁当电话被密码/模式锁定时的电话...这是我无法显示我想要的用户界面的问题吗?它如何处理来电?请给我一些解决方案

我提到的链接是

How can I unlock the screen programmatically in Android?

Unlock the Android Lockscreen

How do I prevent an Android device from going to sleep programmatically?

https://stackoverflow.com/questions/7006894/how-to-unlack-the-screen-and-power-on-when-my-application-is-in-background-when

Force Screen On

unlock screen while in call android

Android: Turn screen ON and notify user

How to launch an activity when lock screen is enabled?

Android activity over default lock screen

Android Create An Activity That Float Over Lockscreen

Unlock Android phone programmatically?

How to display Activity when the screen is locked?

How to unlock the device when my activity will be launched programmatically?

Android: How to turn screen on and off programmatically?

https://stackoverflow.com/questions/10590918/how-to-display-dialog-when-user-get-incoming-call-on-default-call-screen-in-andr

How to show incoming call notification in android application

How to display Activity when the screen is locked?

How to dismiss lock screen?

problem with KeyGuardManager

How unlock and lock screen programatically in android

How to unlock the device when my activity will be launched programmatically?

Get the Sip Incoming call id

How to notify SIP client when there is an incoming call on another phone

Can an activity receive an unordered broadcast(incoming call) intent before system's default receiver?

提前致谢。

最佳答案

对我来说,下面的代码效果很好。

@Override
protected void onCreate() {
KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
keyguard = km.newKeyguardLock("MyApp");
}
//when we need to unlock screen
@Override
protected void onResume() {
keyguard.disableKeyguard();
}
@Override
protected void onPause() {
keyguard.enableKeyguard();
}

记得加上权限

<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />

关于android - [android][lock_screen] 来电时解锁待机屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10716272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com