我的应用程序在Android 6.0上崩溃了。我知道这是广告网络需要的危险许可造成的。我已经请求并同意我的应用程序中需要的这些权限,Write_external_storage,read_phone_state,但它仍然崩溃。怎么了?我使用unity 5.3.5f1。
genymotion的Logcat:
11-25 04:22:47.034 I / art(21550):拒绝重新启动先前失败的课程 java.lang.Class中
11-25 04:22:47.034我/艺术(21550):拒绝重新启动 以前失败的课程 java.lang.Class中
11-25 04:22:47.036 W / Ads(21550):遇到问题 广告回复。 ErrorCode:2
11-25 04:22:47.142 W / ActivityManager(20685):活动暂停超时 对于ActivityRecord {bed9d6c u0 com.candyjuice / com.unity3d.player.UnityPlayerActivity t4 f}
11-25 04:22:47.210 W / EGL_emulation(21094):eglSurfaceAttrib not not not 实施
11-25 04:22:47.210 W / OpenGLRenderer(21094):无法设置 表面上的EGL_SWAP_BEHAVIOR为0xdecd1d80,错误= EGL_SUCCESS
11-25 04:22:47.228 W / Ads(21550):遇到问题 广告回复。 ErrorCode:2
11-25 04:22:47.290 I / GlobalDismissManager(21481):未配置发件人
11-25 04:22:47.291 D / AlertService(21481):开头 updateAlertNotification
11-25 04:22:47.294 D / AlertService(21481):没有被解雇或预定的警报
11-25 04:22:47.296 D / AlertService(21481):使用安排下一个警报 AlarmScheduler。 sEventReminderReceived:null
11-25 04:22:47.299 D / AlarmScheduler(21481):未找到任何事件 在一周内。
11-25 04:22:48.756 W / GooglePlayServicesUtil(21550):Google Play商店 不见了。
11-25 04:22:48.756 W / VungleNetwork(21550): java.net.UnknownHostException:无法解析主机 " api.vungle.com":没有与主机名相关联的地址
11-25 04:22:48.763 W / VungleNetwork(21550): java.net.UnknownHostException:无法解析主机 " api.vungle.com":没有与主机名相关联的地址
11-25 04:22:48.820 I / OneSignal(21550):GetUnsentActiveTime:0
11-25 04:22:48.820 I / OneSignal(21550):SaveUnsentActiveTime:2
11-25 04:22:48.851 W / AudioTrack(20685):AUDIO_OUTPUT_FLAG_FAST被拒绝 客户;传输4,跟踪48000 Hz,输出44100 Hz
11-25 04:22:48.867 I / Process(21550):发送信号。 PID:21550 SIG: 9
11-25 04:22:48.890 E / Surface(20685):getSlotFromBufferLocked:unknown buffer:0xf2cb6600
11-25 04:22:48.893 D / OpenGLRenderer(20685):endAllStagingAnimators on 0xd9931b00(RippleDrawable),句柄为0xdcc0be00
11-25 04:22:48.896 E / JavaBinder(20685):!!!失败的粘合剂交易 ! (包裹大小= 104)
11-25 04:22:48.896 W / InputMethodManagerService(20685):得到了 RemoteException向pid 21550 uid发送setActive(false)通知 10060
11-25 04:22:48.896 E / JavaBinder(20685):!!!失败的粘合剂交易 ! (包裹大小= 104)
11-25 04:22:48.899 D / GraphicsStats(20685):缓冲计数:3
11-25 04:22:48.899 I / WindowState(20685):胜利死亡:窗口{d9b3a6e u0 com.candyjuice / com.unity3d.player.UnityPlayerActivity}
11-25 04:22:48.899 W / WindowManager(20685):强制删除子胜利 窗口{3bca2c7 u0 SurfaceView}来自容器窗口{d9b3a6e u0 com.candyjuice / com.unity3d.player.UnityPlayerActivity}
11-25 04:22:48.899 W / MediaFocusControl(20685):AudioFocus音频 焦点客户死了
11-25 04:22:48.899 I / MediaFocusControl(20685):AudioFocus removeFocusStackEntry():删除条目 android.os.BinderProxy@dd420f4
11-25 04:22:48.902 W / WindowManager(20685):查找窗口失败
11-25 04:22:48.902 W / WindowManager(20685): java.lang.IllegalArgumentException:请求的窗口 android.os.BinderProxy@f7e5388不存在
11-25 04:22:48.902 W / WindowManager(20685):at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8733)
11-25 04:22:48.902 W / WindowManager(20685):at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8724)
11-25 04:22:48.902 W / WindowManager(20685):at com.android.server.wm.WindowState $ DeathRecipient.binderDied(WindowState.java:1209)
11-25 04:22:48.902 W / WindowManager(20685):at android.os.BinderProxy.sendDeathNotice(Binder.java:558)
11-25 04:22:48.902 I / WindowState(20685):胜利死亡:null
11-25 04:22:48.904 I / ActivityManager(20685):处理com.candyjuice (pid 21550)已经去世了
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
{
Log.i("NoodlePermissionGranter", "onRequestPermissionsResult");
if (requestCode != PERMISSIONS_REQUEST_CODE)
return;
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted, yay! Do the
// contacts-related task you need to do.
Log.i("NoodlePermissionGranter", PERMISSION_GRANTED);
UnityPlayer.UnitySendMessage(UNITY_CALLBACK_GAMEOBJECT_NAME, UNITY_CALLBACK_METHOD_NAME, PERMISSION_GRANTED);
} else {
// permission denied, boo! Disable the
// functionality that depends on this permission.
Log.i("NoodlePermissionGranter",PERMISSION_DENIED);
UnityPlayer.UnitySendMessage(UNITY_CALLBACK_GAMEOBJECT_NAME, UNITY_CALLBACK_METHOD_NAME, PERMISSION_DENIED);
}
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.remove(this);
fragmentTransaction.commit();
//SDD
// shouldBeOkayToStartTheApplicationNow();
}
};
答案 0 :(得分:1)
您必须实际请求并检查用户是否授予了使用
的权限在void onCreate(Bundle savedInstanceState)方法
中检查此项>>>res
['dirty room', 'dormitory']
然后覆盖onRequestPermissionsResult方法
If (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, STORAGE_PERMISSION_RC);
return;
}