Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Android】录屏闪退 #94

Open
loop6r opened this issue Jul 7, 2020 · 5 comments
Open

【Android】录屏闪退 #94

loop6r opened this issue Jul 7, 2020 · 5 comments

Comments

@loop6r
Copy link

loop6r commented Jul 7, 2020

【当前现象】开启录屏后闪退
【集成包】Smart SDK版本:7.4.9209
【机型】android 10机型

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=100, result=-1, data=Intent { (has extras) }} to activity {com.tencent.rtmp.video.TXScreenCapture$TXScreenCaptureAssistantActivity}: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
at android.app.ActivityThread.deliverResults(ActivityThread.java:5587)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:5628)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8347)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
Caused by: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
at android.os.Parcel.createException(Parcel.java:2071)
at android.os.Parcel.readException(Parcel.java:2039)
at android.os.Parcel.readException(Parcel.java:1987)
at android.media.projection.IMediaProjection$Stub$Proxy.start(IMediaProjection.java:231)
at android.media.projection.MediaProjection.(MediaProjection.java:75)
at android.media.projection.MediaProjectionManager.getMediaProjection(MediaProjectionManager.java:104)
at com.tencent.rtmp.video.TXScreenCapture$TXScreenCaptureAssistantActivity.onActivityResult(TXScreenCapture.java:45)
at android.app.Activity.dispatchActivityResult(Activity.java:8412)
at android.app.ActivityThread.deliverResults(ActivityThread.java:5580)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:5628) 
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473) 
at android.os.Handler.dispatchMessage(Handler.java:110) 
at android.os.Looper.loop(Looper.java:219) 
at android.app.ActivityThread.main(ActivityThread.java:8347) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055) 
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(libmapleservices.so:16270636)
at android.media.projection.IMediaProjection$Stub.onTransact(libmapleframework.so:18629684)
at android.os.Binder.execTransactInternal(libmapleframework.so:5520784)
at android.os.Binder.execTransact(libmapleframework.so:5519996)

@loop6r
Copy link
Author

loop6r commented Jul 7, 2020

compileSdk 和targetSdk 均为29 ,有无非降级的解决方案

@lg20188
Copy link

lg20188 commented Sep 9, 2020

android:foregroundServiceType="mediaProjection"

清单文件添加这2个 https://blog.csdn.net/qq_36332133/article/details/96485285

@loop6r
Copy link
Author

loop6r commented Sep 10, 2020

`
public class TXScreenCapture {
public TXScreenCapture() {
}

@TargetApi(21)
public static class TXScreenCaptureAssistantActivity extends Activity {
    private static final String TAG = "TXScreenCaptureAssistantActivity";
    private static final int REQUEST_CODE = 100;
    private MediaProjectionManager mMediaProjectionManager;

    public TXScreenCaptureAssistantActivity() {
    }

    public void onCreate(Bundle var1) {
        super.onCreate(var1);
        TXCLog.i("TXScreenCaptureAssistantActivity", "onCreate " + this);
        this.requestWindowFeature(1);
        this.mMediaProjectionManager = (MediaProjectionManager)this.getSystemService("media_projection");
        Intent var2 = this.mMediaProjectionManager.createScreenCaptureIntent();

        try {
            this.startActivityForResult(var2, 100);
        } catch (Exception var4) {
            TXCLog.e("TXScreenCaptureAssistantActivity", "start permission activity failed. " + var4);
            d.a(this).a((MediaProjection)null);
            this.finish();
        }

    }

    public void onActivityResult(int var1, int var2, Intent var3) {
        TXCLog.i("TXScreenCaptureAssistantActivity", "onActivityResult " + this);
        MediaProjection var4 = this.mMediaProjectionManager.getMediaProjection(var2, var3);
        d.a(this).a(var4);
        this.finish();
    }

    protected void onDestroy() {
        super.onDestroy();
        TXCLog.i("TXScreenCaptureAssistantActivity", "onDestroy " + this);
    }
}

}

`

这个类是sdk内部的,按照文章的说法,也是sdk做兼容

@keshuangjie
Copy link

这个问题最新SDK还没有修复

@JohnsCui
Copy link

遇到了同样的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants