Exemplo n.º 1
0
 public static AndroidJavaObject FromFile(string filePath)
 {
     using (var uriClass = new AndroidJavaClass(C.UriClass))
     {
         return(uriClass.CallStaticAJO("fromFile", AGUtils.NewJavaFile(filePath)));
     }
 }
        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);
        }