/// <summary> /// Capture an image from the device camera. /// </summary> /// <param name="maxSize">Max captured media thumbnail size that will be transferred to Unity</param> /// <param name="callback">Operation result callback.</param> public static void CaptureImage(int maxSize, Action <AN_CameraCaptureResult> callback) { var permissions = new[] { AMM_ManifestPermission.CAMERA, AMM_ManifestPermission.READ_EXTERNAL_STORAGE, AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE }; AN_PermissionsUtility.TryToResolvePermission( new [] { AMM_ManifestPermission.READ_EXTERNAL_STORAGE, AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE }, (granted) => { AN_GalleryInternal.PickImageFromGallery(maxSize, AN_GalleryChooseType.CAPTURE_PICTURE, false, (result) => { AN_CameraCaptureResult captureResult; if (result.IsFailed) { captureResult = new AN_CameraCaptureResult(result.Error); } else { captureResult = new AN_CameraCaptureResult(result.Media[0]); } callback.Invoke(captureResult); }); }); }
//-------------------------------------- // Public Methods //-------------------------------------- public void Share(Action callback = null) { if (Application.isEditor) { SA_Coroutine.WaitForSeconds(1, () => { if (callback != null) { callback.Invoke(); } }); return; } AN_PermissionsUtility.TryToResolvePermission(new [] { AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE, AMM_ManifestPermission.READ_EXTERNAL_STORAGE }, (granted) => { if (!granted) { AN_Logger.LogError("User haven't granted required sharing permissions: " + "WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE. " + "Sharing may not be fully completed."); } ShowSharingDialog(callback); }); }
private void StartRequestAccessFlow(Action <AuthorizationStatus> callback) { switch (Application.platform) { case RuntimePlatform.Android: IOSRequestAccess(callback); break; case RuntimePlatform.IPhonePlayer: AN_PermissionsUtility.TryToResolvePermission(AndroidPermissions, (granted) => { if (granted) { callback.Invoke(AuthorizationStatus.Granted); } else { callback.Invoke(AuthorizationStatus.Denied); } }); break; default: UM_EditorAPIEmulator.WaitForNetwork(() => { callback.Invoke(AuthorizationStatus.Granted); }); break; } }
public override void RequestAuthorization(Action <SA_Result> callback) { AN_PermissionsUtility.TryToResolvePermission(AMM_ManifestPermission.WAKE_LOCK, (granted) => { if (granted) { callback.Invoke(new SA_Result()); } else { var error = new SA_Error(100, "User declined"); callback.Invoke(new SA_Result(error)); } }); }
/// <summary> /// Starts pick media from a gallery flow. /// </summary> /// <param name="callback"></param> public void Show(Action <AN_GalleryPickResult> callback) { AN_PermissionsUtility.TryToResolvePermission( new [] { AMM_ManifestPermission.READ_EXTERNAL_STORAGE, AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE }, (granted) => { var type = AN_GalleryChooseType.PICK_PICTURE; if (m_types.Contains(AN_MediaType.Image) && m_types.Contains(AN_MediaType.Video)) { type = AN_GalleryChooseType.PICK_PICTURE_OR_VIDEO; } else { if (m_types.Contains(AN_MediaType.Video)) { type = AN_GalleryChooseType.PICK_VIDEO; } } AN_GalleryInternal.PickImageFromGallery(m_maxSize, type, m_allowMultiSelect, callback); }); }
/// <summary> /// Method will retrive all contacts from user phone address book /// </summary> /// <param name="callback">address book contacts list will be delivered via this callback</param> /// <param name="checkForPermission"> /// Will automatically check for READ_CONTACTS permissions. /// Please note That SupportV4 lib is required to prefrom the permission check /// </param> public static void Retrieve(Action <AN_ContactsResult> callback, bool checkForPermission = true) { if (Application.isEditor) { SA_Coroutine.WaitForSeconds(1, () => { var result = new AN_ContactsResult(); callback.Invoke(result); }); return; } AN_PermissionsUtility.TryToResolvePermission(AMM_ManifestPermission.READ_CONTACTS, (granted) => { if (granted) { RetrieveNative(callback); } else { var error = new SA_Error(1, "READ_CONTACTS permission is missing"); var contactsResult = new AN_ContactsResult(error); callback.Invoke(contactsResult); } }); }