requestScreenCapture()出现崩溃
执行main.js会出现崩溃的情况。刚启动App执行不会,过一段时间(大概7、8分钟或者更久)再执行有很大的概率会出现
没有使用连接到计算机功能
autox没有发现这个情况
main.js
var tool = require("tool.js");
tool.js
if (!requestScreenCapture()) {
toast("请求截图失败");
exit();
}
11月21日 19:04:51 后面又试了一下运行下面,也会出现崩溃: 重启autojs6执行一次main.js,然后过一段时间再执行一次
main.js
requestScreenCapture();
报错:
Version: 2180
Android: 31
java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
java.lang.RuntimeException:Failure delivering result ResultInfo{who=null, request=17777, result=-1, data=Intent { (has extras) }} to activity {org.autojs.autojs6/org.autojs.autojs.core.image.capture.ScreenCaptureRequestActivity}: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
android.app.ActivityThread.deliverResults(ActivityThread.java:5481)
......
Caused by:
java.lang.SecurityException:Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
android.os.Parcel.createExceptionOrNull(Parcel.java:2455)
android.os.Parcel.createException(Parcel.java:2439)
android.os.Parcel.readException(Parcel.java:2422)
android.os.Parcel.readException(Parcel.java:2364)
android.media.projection.IMediaProjection$Stub$Proxy.start(IMediaProjection.java:235)
android.media.projection.MediaProjection.
11月21日 19:10:29
报错2: Version: 2180 Android: 31 android.os.RemoteException: Remote stack trace: at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(MediaProjectionManagerService.java:557) at android.media.projection.IMediaProjection$Stub.onTransact(IMediaProjection.java:137) at android.os.Binder.execTransactInternal(Binder.java:1190) at android.os.Binder.execTransact(Binder.java:1149)
java.lang.RuntimeException:Failure delivering result ResultInfo{who=null, request=17777, result=-1, data=Intent { (has extras) }} to activity {org.autojs.autojs6/org.autojs.autojs.core.image.capture.ScreenCaptureRequestActivity}: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION android.app.ActivityThread.deliverResults(ActivityThread.java:5481) ...... Caused by: android.os.RemoteException:Remote stack trace: at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(MediaProjectionManagerService.java:557) at android.media.projection.IMediaProjection$Stub.onTransact(IMediaProjection.java:137) at android.os.Binder.execTransactInternal(Binder.java:1190) at android.os.Binder.execTransact(Binder.java:1149)
I also noticed after installation as soon as I flipped the switch for foreground service it crashed. My phone is Samsung S22 Sm-S901W on Android 14 if you need to know for more information