gpt4 book ai didi

android - startActivity 在 Android 11 中抛出异常

转载 作者:行者123 更新时间:2023-12-05 00:04:28 28 4
gpt4 key购买 nike

我在尝试从我的服务中使用 startActivity 时遇到问题。

我正在使用 ADB 命令 - “appops set com.neexperience.android SYSTEM_ALERT_WINDOW allow”授予应用从后台启动 Activity 的权限。

我的服务在 Android 10 及更低版本上运行良好。我使用的设备是:pixel 2、pixel 3 xl、pixel 4、pixel 4 a 和 pixel 5。

异常:

IntentStarted during UNKNOWN. Intent { cmp=com.nexperience.android/.MPScreenCapActivity (has extras) }
<200804 11:32:15.446> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] java.lang.Throwable: EventSequenceValidator#getStackTrace
<200804 11:32:15.447> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] at com.google.android.startop.iorap.EventSequenceValidator.logWarningWithStackTrace(EventSequenceValidator.java:260)
<200804 11:32:15.447> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] at com.google.android.startop.iorap.EventSequenceValidator.onIntentStarted(EventSequenceValidator.java:106)
<200804 11:32:15.447> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] at com.android.server.wm.LaunchObserverRegistryImpl.handleOnIntentStarted(LaunchObserverRegistryImpl.java:139)
<200804 11:32:15.447> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] at com.android.server.wm.LaunchObserverRegistryImpl.lambda$veRn_GhgLZLlOHOJ0ZYT6KcfYqo(Unknown Source:0)
<200804 11:32:15.447> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] at com.android.server.wm.-$$Lambda$LaunchObserverRegistryImpl$veRn_GhgLZLlOHOJ0ZYT6KcfYqo.accept(Unknown Source:10)
<200804 11:32:15.447> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] at com.android.internal.util.function.pooled.PooledLambdaImpl.doInvoke(PooledLambdaImpl.java:292)
<200804 11:32:15.447> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] at com.android.internal.util.function.pooled.PooledLambdaImpl.invoke(PooledLambdaImpl.java:201)
<200804 11:32:15.447> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] at com.android.internal.util.function.pooled.OmniFunction.run(OmniFunction.java:97)
<200804 11:32:15.447> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] at android.os.Handler.handleCallback(Handler.java:938)
<200804 11:32:15.447> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] at android.os.Handler.dispatchMessage(Handler.java:99)
<200804 11:32:15.448> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] at android.os.Looper.loop(Looper.java:223)
<200804 11:32:15.448> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] at android.os.HandlerThread.run(HandlerThread.java:67)
<200804 11:32:15.448> DEBUG [Y17HPU" logcat -v long] (32768)/syslog] at com.android.server.ServiceThread.run(ServiceThread.java:44)

最佳答案

问题是我需要在 list 中请求 SYSTEM_ALERT_WINDOW 权限:

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

并使用 pm grant 而非 appops set 授予权限。

关于android - startActivity 在 Android 11 中抛出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63261047/

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