소스 검색

android请求权限

guodong 2 년 전
부모
커밋
94a6ed0bd5
2개의 변경된 파일14개의 추가작업 그리고 4개의 파일을 삭제
  1. 13 3
      GameClient/Assets/Game/HotUpdate/Views/DressUp/PhotographSaveView.cs
  2. 1 1
      GameClient/ProjectSettings/ProjectSettings.asset

+ 13 - 3
GameClient/Assets/Game/HotUpdate/Views/DressUp/PhotographSaveView.cs

@@ -7,6 +7,7 @@ using ET;
 using FairyGUI;
 using UI.DressUp;
 using UnityEngine;
+using UnityEngine.Android;
 
 namespace GFGGame
 {
@@ -64,9 +65,18 @@ namespace GFGGame
 
         private void OnClickBtnSave()
         {
-            string fileName = "wsj" + TimeHelper.ServerNowSecs + ".jpg";
-            PhotographUtil.Instance.SavePicturoToLocal(bytes, fileName);
-            _ui.m_btnSave.touchable = false;
+            //检查用户是否已授予对需要授权的设备资源或信息的访问权。
+            if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite))
+            {
+                //请求用户授权访问需要授权的设备资源或信息.
+                Permission.RequestUserPermission(Permission.ExternalStorageWrite);
+            }
+            if (Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite))
+            {
+                string fileName = "wsj" + TimeHelper.ServerNowSecs + ".jpg";
+                PhotographUtil.Instance.SavePicturoToLocal(bytes, fileName);
+                _ui.m_btnSave.touchable = false;
+            }
 
         }
 

+ 1 - 1
GameClient/ProjectSettings/ProjectSettings.asset

@@ -180,7 +180,7 @@ PlayerSettings:
   iPhoneStrippingLevel: 0
   iPhoneScriptCallOptimization: 0
   ForceInternetPermission: 0
-  ForceSDCardPermission: 1
+  ForceSDCardPermission: 0
   CreateWallpaper: 0
   APKExpansionFiles: 0
   keepLoadedShadersAlive: 0