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

Error receiving broadcast Intent { act=com.anzh.netflex.andpermission.bridge.Thread-2 flg=0x10 } in com.yanzhenjie.permission.bridge.Messenger@3ea4e77 #674

Open
zhangzheng567 opened this issue Aug 17, 2021 · 1 comment

Comments

@zhangzheng567
Copy link

Process: com.anzh.netflex:permission, PID: 13544
java.lang.RuntimeException: Error receiving broadcast Intent { act=com.anzh.netflex.andpermission.bridge.Thread-2 flg=0x10 } in com.yanzhenjie.permission.bridge.Messenger@3ea4e77
at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1560)
at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:221)
at android.app.ActivityThread.main(ActivityThread.java:7565)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:696)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:659)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:552)
at androidx.appcompat.app.AppCompatDialog.setContentView(AppCompatDialog.java:95)
at com.yanzhenjie.permission.task.WaitDialog.(WaitDialog.java:32)
at com.yanzhenjie.permission.task.TaskExecutor.(TaskExecutor.java:35)
at com.yanzhenjie.permission.runtime.MRequest$1.(MRequest.java:101)
at com.yanzhenjie.permission.runtime.MRequest.onCallback(MRequest.java:101)
at com.yanzhenjie.permission.bridge.RequestExecutor.onCallback(RequestExecutor.java:115)
at com.yanzhenjie.permission.bridge.Messenger.onReceive(Messenger.java:54)
at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1550)
at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2) 
at android.os.Handler.handleCallback(Handler.java:883) 
at android.os.Handler.dispatchMessage(Handler.java:100) 
at android.os.Looper.loop(Looper.java:221) 
at android.app.ActivityThread.main(ActivityThread.java:7565) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935) 

@1982582704
Copy link

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {// android 11  且 不是已经被拒绝
        // 先判断有没有权限
        if (!Environment.isExternalStorageManager()) {
            Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
            intent.setData(Uri.parse("package:" + getPackageName()));
            startActivityForResult(intent, 1024);
        }
    }

// 带回授权结果
@OverRide
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1024 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// 检查是否有权限
if (Environment.isExternalStorageManager()) {
// 授权成功
// todo
} else {
// 授权失败

        }
    }
}

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

2 participants