3

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

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

我的服务在 Android 10 及更低版本上运行良好。我正在使用的设备是:像素 2、像素 3 xl、像素 4、像素 4 a 和像素 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)
4

1 回答 1

0

问题是我需要SYSTEM_ALERT_WINDOW在清单中请求许可:

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

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

于 2020-09-21T06:49:17.590 回答