由以下原因引起:java.lang.SecurityException:PendingIntent的目标包不能与请求包相同

时间:2018-06-29 12:32:53

标签: android android-instant-apps

您好,在位置权限请求成功后出现此错误。权限成功后,可以使用LocationService请求位置,如下所示。

 LocationServices.GeofencingApi.addGeofences(mApiClient, mGeofenceList, mGeofenceRequestIntent);

我在Google上搜索了此内容,因为这是即时应用程序模块,我无法找到确切的解决方案来解决此问题。但是在我的项目apk模块位置中请求工作文件没有任何问题。

这是我的完整日志

  E/Isotope: UID: [10135]  PID: [21567] IActivityManagerProxy : Instant app: xxx.yyy.zzz crashed: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=42, result=0, data=Intent { (has extras) }} to activity {xxx.yyy.zzz/com.karumi.dexter.DexterActivity}: java.lang.SecurityException: PendingIntent's target package can't be different to the request package.
    at android.app.ActivityThread.deliverResults(ActivityThread.java:4130)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:4173)
    at android.app.ActivityThread.-wrap20(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6165)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
 Caused by: java.lang.SecurityException: PendingIntent's target package can't be different to the request package.
    at android.os.Parcel.readException(Parcel.java:1684)
    at android.os.Parcel.readException(Parcel.java:1637)
    at com.google.android.gms.location.internal.zzi$zza$zza.zza(Unknown Source)
    at com.google.android.gms.location.internal.zzl.zza(Unknown Source)
    at com.google.android.gms.location.internal.zzf$1.zza(Unknown Source)
    at com.google.android.gms.location.internal.zzf$1.zza(Unknown Source)
    at com.google.android.gms.common.api.internal.zza$zza.zzb(Unknown Source)
    at com.google.android.gms.common.api.internal.zzg.zza(Unknown Source)
    at com.google.android.gms.common.api.internal.zzg.zzb(Unknown Source)
    at com.google.android.gms.common.api.internal.zzl.zzb(Unknown Source)
    at com.google.android.gms.common.api.internal.zzj.zzb(Unknown Source)
    at com.google.android.gms.location.internal.zzf.addGeofences(Unknown Source)
    at com.google.android.gms.location.internal.zzf.addGeofences(Unknown Source)
    at xxx.yyy.zzz.activity.HomeActivity$1.onPermissionGranted(HomeActivity.java:219)
    at com.karumi.dexter.MultiplePermissionsListenerToPermissionListenerAdapter.onPermissionsChecked(MultiplePermissionsListenerToPermissionListenerAdapter.java:48)
    at com.karumi.dexter.MultiplePermissionListenerThreadDecorator$1.run(MultiplePermissionListenerThreadDecorator.java:45)
    at com.karumi.dexter.MainThread.execute(MainThread.java:32)
    at com.karumi.dexter.MultiplePermissionListenerThreadDecorator.onPermissionsChecked(MultiplePermissionListenerThreadDecorator.java:43)
    at com.karumi.dexter.DexterInstance.onPermissionsChecked(DexterInstance.java:278)
    at com.karumi.dexter.DexterInstance.updatePermissionsAsGranted(DexterInstance.java:252)
    at com.karumi.dexter.DexterInstance.onPermissionRequestGranted(DexterInstance.java:141)
    at com.karumi.dexter.Dexter.onPermissionsRequested(Dexter.java:175)
    at com.karumi.dexter.DexterActivity.onRequestPermissionsResult(DexterActivity.java:54)
    at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7098)
    at android.app.Activity.dispatchActivityResult(Activity.java:6950)

待定意图的代码

  private PendingIntent getGeofenceTransitionPendingIntent() {
    Intent intent = new Intent(xxx.yyy.zzz.activity.HomeActivity.this, xxx.yyy.zzz.activity.GeofenceTransitionsIntentService.class);
    return PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}

0 个答案:

没有答案