如何在 Android 10 中的屏幕锁定屏幕时启动活动

时间:2020-12-22 12:07:33

标签: android android-intent android-activity android-10.0

我必须在设备锁定时启动一个活动,我使用以下代码从服务启动活动。它在 android 10 设备下运行良好。

val callIntent = Intent(this, CallActivity::class.java)
callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
callIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
callIntent.putExtra(EXTRA_CALL_TYPE, callType)
callIntent.putExtra(EXTRA_CALL_DIRECTION, callDirection)
startActivity(callIntent)

此代码在 Android 10 中不起作用,在 Android 10 中以任何其他方式启动 Activity

2 个答案:

答案 0 :(得分:1)

您应该使用 fullScreenIntent 发送通知。

答案 1 :(得分:0)

我认为您需要获得后台服务的许可