欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

记录unity 权限启动跳过 弹出对话框

程序员文章站 2022-06-05 14:19:41
...

<meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />

在<application> 中添加 可以跳过启动app 弹出很多对话框 导致 体验不友好,不过要在app中自己做一次检测

public int checkAllPermissions(){
	  if(Build.VERSION.SDK_INT >= 23){
		 String permissions[] = {Manifest.permission.RECORD_AUDIO,
	                Manifest.permission.ACCESS_NETWORK_STATE,
	                Manifest.permission.INTERNET,
	                Manifest.permission.BLUETOOTH,
	                Manifest.permission.BLUETOOTH_ADMIN,
	                Manifest.permission.ACCESS_FINE_LOCATION,
	                Manifest.permission.ACCESS_COARSE_LOCATION,
	                Manifest.permission.MODIFY_AUDIO_SETTINGS,
	                Manifest.permission.READ_PHONE_STATE,
	                Manifest.permission.WRITE_EXTERNAL_STORAGE,
	                Manifest.permission.READ_EXTERNAL_STORAGE
	        };
	        ArrayList<String> toApplyList = new ArrayList<String>();
	        for (String perm : permissions) {
	            if (PackageManager.PERMISSION_GRANTED != AppConst.CurActivity.checkSelfPermission(perm)){
	                toApplyList.add(perm);
	            }
	        }
	        String tmpList[] = new String[toApplyList.size()];
	        if (!toApplyList.isEmpty()) {
	        	AppConst.CurActivity.requestPermissions(toApplyList.toArray(tmpList), 123);
	        	return 0;
	        } 
	 	}
	  return 1;
  }