什么会导致在启动活动时调用Context.checkPermission()?

时间:2016-05-19 16:10:38

标签: android android-6.0-marshmallow

我有一个已发布的应用程序崩溃在客户的设备上(但我无法自己重现)。

他们为我提供了一些日志信息:

05-17 16:56:34.884 31256 31256 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aaa.bbb/com.aaa.ccc.activity.UserLaunch}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.Context.checkPermission(java.lang.String, int, int)' on a null object reference
05-17 16:56:34.884 31256 31256 E AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2434)
05-17 16:56:34.884 31256 31256 E AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
05-17 16:56:34.884 31256 31256 E AndroidRuntime:     at android.app.ActivityThread.access$900(ActivityThread.java:157)
05-17 16:56:34.884 31256 31256 E AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
05-17 16:56:34.884 31256 31256 E AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
05-17 16:56:34.884 31256 31256 E AndroidRuntime:     at android.os.Looper.loop(Looper.java:148)
05-17 16:56:34.884 31256 31256 E AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5551)
05-17 16:56:34.884 31256 31256 E AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
05-17 16:56:34.884 31256 31256 E AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)

然而,UserLaunch活动不会调用checkPermission(),实际上没有任何地方调用checkPermission()。 因此,我想知道是否还有其他因素会间接调用checkPermission()?

调用checkSelfPermission()会导致对checkPermission()的间接调用吗?

1 个答案:

答案 0 :(得分:0)

checkSelfPermission()在内部调用方法检查权限。请确保将当前的Activity引用传递给CheckSelfPermision。像UserLaunch.this