Example #1
0
 //private GameObject galleryBtn;
 private void Start()
 {
     if (!AndroidUtils.IsPermitted(AndroidPermission.ACCESS_FINE_LOCATION))//test request permission
     {
         AndroidUtils.RequestPermission(AndroidPermission.ACCESS_FINE_LOCATION);
     }
     androidUtils = FindObjectOfType <AndroidUtils>();
 }
Example #2
0
    private IEnumerator registerPermissions()
    {
        if (!AndroidUtils.IsPermitted(AndroidPermission.WRITE_EXTERNAL_STORAGE))
        {
            AndroidUtils.RequestPermission(AndroidPermission.WRITE_EXTERNAL_STORAGE);
        }
        yield return(null);

        if (!AndroidUtils.IsPermitted(AndroidPermission.RECORD_AUDIO))//request this permission to record audio for screen record
        {
            AndroidUtils.RequestPermission(AndroidPermission.RECORD_AUDIO);
        }
    }
Example #3
0
 public void SaveVideoToGallery()
 {
     //RECORD_AUDIO is declared inside plugin manifest but we need to request it manualy.Use call back to handle when user didn't accept the permsission
     if (!AndroidUtils.IsPermitted(AndroidPermission.WRITE_EXTERNAL_STORAGE))//request this permission to write recorded file to disk
     {
         AndroidUtils.RequestPermission(AndroidPermission.WRITE_EXTERNAL_STORAGE);
         onAllowCallback = () => { StartCoroutine(_SaveVideoToGallery()); };
         onDenyCallback  = () => { ShowToast("Need WRITE_EXTERNAL_STORAGE to save video"); };
         onDenyAndNeverAskAgainCallback = () => { ShowToast("Need WRITE_EXTERNAL_STORAGE to save video"); };
     }
     else
     {
         StartCoroutine(_SaveVideoToGallery());
     }
 }
Example #4
0
    public void StartRecording()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        if (!AndroidUtils.IsPermitted(AndroidPermission.RECORD_AUDIO))//RECORD_AUDIO is declared inside plugin manifest but we need to request it manualy
        {
            AndroidUtils.RequestPermission(AndroidPermission.RECORD_AUDIO);
            onAllowCallback = () =>
            {
                androidRecorder.Call("startRecording");
            };
            onDenyCallback = () => { ShowToast("Need RECORD_AUDIO permission to record voice"); };
            onDenyAndNeverAskAgainCallback = () => { ShowToast("Need RECORD_AUDIO permission to record voice"); };
        }
        else
        {
            androidRecorder.Call("startRecording");
        }
#endif
    }
Example #5
0
    //Call this func before you start record video
    public void PrepareRecorder()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        //RECORD_AUDIO is declared inside plugin manifest but we need to request it manualy
        if (!AndroidUtils.IsPermitted(AndroidPermission.RECORD_AUDIO))//request this permission to record audio for screen record
        {
            AndroidUtils.RequestPermission(AndroidPermission.RECORD_AUDIO);
            onAllowCallback = () =>
            {
                androidRecorder.Call("setFileName", VIDEO_NAME);
                androidRecorder.Call("prepareRecorder");
            };
            onDenyCallback = () => { ShowToast("Need microphone to record voice"); };
            onDenyAndNeverAskAgainCallback = () => { ShowToast("Need microphone to record voice"); };
        }
        else
        {
            androidRecorder.Call("setFileName", VIDEO_NAME);
            androidRecorder.Call("prepareRecorder");
        }
#endif
    }