yanzhenjie / AndPermission

:strawberry: Permissions manager for Android platform.
https://yanzhenjie.com/AndPermission
Apache License 2.0
6.63k stars 1.1k forks source link

PermissionActivity主题问题导致的闪退 #149

Closed AmoyJJ closed 6 years ago

AmoyJJ commented 6 years ago
java.lang.RuntimeException:Failure delivering result ResultInfo{who=@android:requestPermissions:, request=1, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS FromType=0xffffffff (has extras) }} to activity {papau.cn/com.yanzhenjie.permission.PermissionActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

2 android.app.ActivityThread.deliverResults(ActivityThread.java:4137) 3 ...... 4 Caused by: 5 java.lang.IllegalStateException:You need to use a Theme.AppCompat theme (or descendant) with this activity. 6 android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java) 7 android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java) 8 android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java) 9 android.support.v7.app.AppCompatDialog.setContentView(AppCompatDialog.java) 10 android.support.v7.app.AlertController.installContent(AlertController.java) 11 android.support.v7.app.AlertDialog.onCreate(AlertDialog.java) 12 android.app.Dialog.dispatchOnCreate(Dialog.java:404) 13 android.app.Dialog.show(Dialog.java:301) 14 android.support.v7.app.AlertDialog$Builder.show(AlertDialog.java) 15 papau.cn.engine.AndPermissionEngine$1.showRequestPermissionRationale(AndPermissionEngine.java) 16 com.yanzhenjie.permission.DefaultRequest.start(DefaultRequest.java) 17 papau.cn.engine.AndPermissionEngine$2.onFailed(AndPermissionEngine.java) 18 com.yanzhenjie.permission.DefaultRequest.callbackFailed(DefaultRequest.java) 19 com.yanzhenjie.permission.DefaultRequest.onRequestPermissionsResult(DefaultRequest.java) 20 com.yanzhenjie.permission.PermissionActivity.onRequestPermissionsResult(PermissionActivity.java)

yanzhenjie commented 6 years ago

下次提问时请按照这个格式:提示
应该不会出现这个问题,可能和你项目的环境有关,你是否过滤掉了support库。如果还不能解决,请提供更多的判断条件。

目前最新版本是2.0.0-alpha,没有用到AppCompat库,更不应该出现这个问题。可能是回调你的时候,你的Dialog引用了AppComatstyle,麻烦你再检查一下或者提供更多的判断条件。

yuyuyu000 commented 6 years ago

大佬 新版本是否还有 判断是否有权限的方法 如旧版本这个方法AndPermission.hasPermission()

yanzhenjie commented 6 years ago

没有了,使用AndPermissioin就不用做这个判断了。

yuyuyu000 commented 6 years ago

好的 知道了 谢谢您

getglory commented 5 years ago

申请权限时,必须传Activity,不能传Application,否则会因为没有主题导致崩溃。 Fragment中:AndPermission.with(getActivity()).runtime()..... Activity中:AndPermission.with(this).runtime().....

williamlv commented 3 years ago

2.0.3 在public class MainActivity extends UnityPlayerActivity 里调用还是会报错。