public static AndroidJavaObject SaveShareImageToExternalStorage(Texture2D tex2D)
        {
            byte[] encoded      = tex2D.Encode(ImageFormat.PNG);
            string saveFilePath = SaveFileToExternalStorage(encoded, GoodiesShareImageFileName, GoodiesFileFolder);

            return(AndroidUri.FromFile(saveFilePath));
        }
 public static void RefreshGallery(string filePath)
 {
     if (AGDeviceInfo.SDK_INT >= AGDeviceInfo.VersionCodes.KITKAT)
     {
         ScanFile(filePath, null);
     }
     else
     {
         var uri    = AndroidUri.FromFile(filePath);
         var intent = new AndroidIntent(AndroidIntent.ActionMediaMounted, uri);
         AGUtils.SendBroadcast(intent.AJO);
     }
 }
 public static void RefreshGallery(string filePath)
 {
     if (AGDeviceInfo.SDK_INT >= AGDeviceInfo.VersionCodes.KITKAT)
     {
         using (var c = new AndroidJavaClass(MediaScannerConnectionClass))
         {
             c.CallStatic("scanFile", AGUtils.Activity, new[] { filePath }, null, null);
         }
     }
     else
     {
         var uri    = AndroidUri.FromFile(filePath);
         var intent = new AndroidIntent(AndroidIntent.ACTION_MEDIA_MOUNTED, uri);
         AGUtils.SendBroadcast(intent.AJO);
     }
 }
        public static AndroidJavaObject GetUriFromFilePath(string saveFilePath)
        {
            AndroidJavaObject uri;

            if (AGDeviceInfo.SDK_INT >= AGDeviceInfo.VersionCodes.N)
            {
                // Reference: http://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed
                using (var c = new AndroidJavaClass(FileProviderClass))
                {
                    var provider = AGDeviceInfo.GetApplicationPackage() + ".multipicker.fileprovider";
                    uri = c.CallStaticAJO("getUriForFile", AGUtils.Activity, provider, AGUtils.NewJavaFile(saveFilePath));
                }
            }
            else
            {
                uri = AndroidUri.FromFile(saveFilePath);
            }
            return(uri);
        }
        public static AndroidJavaObject SaveShareImageToExternalStorage(Texture2D tex2D)
        {
            // aTODO update : http://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed
            string            saveFilePath = SaveImageToPictures(tex2D, GoodiesShareImageFileName, GoodiesFileFolder, ImageFormat.PNG);
            AndroidJavaObject uri;

            if (AGDeviceInfo.SDK_INT >= AGDeviceInfo.VersionCodes.N)
            {
                using (var c = new AndroidJavaClass(FileProviderClass))
                {
                    var provider = AGDeviceInfo.GetApplicationPackage() + ".multipicker.fileprovider";
                    uri = c.CallStaticAJO("getUriForFile", AGUtils.Activity, provider, AGUtils.NewJavaFile(saveFilePath));
                }
            }
            else
            {
                uri = AndroidUri.FromFile(saveFilePath);
            }
            return(uri);
        }