public static void OpenPdf(string path)
        {
            if (AGUtils.IsNotAndroid())
            {
                return;
            }

            if (!File.Exists(path))
            {
                Debug.LogError("File doesn't exist: " + path);
                return;
            }

            var fileUri = AndroidPersistanceUtilsInternal.GetUriFromFilePath(path);

            var intent = new AndroidIntent(AndroidIntent.ActionView);

            intent.SetDataAndType(fileUri, AndroidIntent.MIMETypePdf);
            intent.SetFlags(AndroidIntent.Flags.GrantReadUriPermission | AndroidIntent.Flags.ActivityClearTop);

            AGUtils.StartActivity(intent.AJO);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// <remarks>
        /// WARNING: This method work on my devices but always crashes on emulators and I can't find a way to fix it.
        /// It may be something with emulator but use this method with care and test careffuly before using it.
        /// </remarks>
        ///
        /// Sets provided image on the provided filepath as wallpaper allowing user to crop beforehand. File MUST exist.
        /// </summary>
        /// <param name="imagePath">File path to the image file</param>
        public static void ShowCropAndSetWallpaperChooser([NotNull] string imagePath)
        {
            if (imagePath == null)
            {
                throw new ArgumentNullException("imagePath");
            }

            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            if (AGDeviceInfo.SDK_INT < AGDeviceInfo.VersionCodes.KITKAT)
            {
                return;
            }

            CheckIfFileExists(imagePath);
            var uri = AndroidPersistanceUtilsInternal.GetUriFromFilePath(imagePath);

            StartCropAndSetWallpaperActivity(uri);
        }
        /// <summary>
        ///  <remarks>
        /// WARNING: This method works on my devices but always crashes on emulators and I can't find a way to fix it.
        /// It may be something with emulator but use this method with care and test carefully before using it.
        /// </remarks>
        ///  Sets provided image on the provided filepath as wallpaper allowing user to crop beforehand. File MUST exist.
        /// </summary>
        /// <param name="imagePath"> A path to the image file </param>
        /// <param name="visibleCropHint">
        /// The rectangular subregion of fullImage that should be displayed as wallpaper. Passing null for this parameter means
        /// that the full image should be displayed if possible given the image's and device's aspect ratios, etc.
        /// </param>
        /// <param name="allowBackup">
        /// True if the OS is permitted to back up this wallpaper image for restore to a future device; false otherwise.
        /// </param>
        /// <param name="which">
        /// Which wallpaper to configure with the new imagery.
        /// </param>
        public static void ShowCropAndSetWallpaperChooser([NotNull] string imagePath,
                                                          AndroidRect visibleCropHint = null, bool allowBackup = true, WallpaperType which = WallpaperType.Unspecified)
        {
            if (imagePath == null)
            {
                throw new ArgumentNullException("imagePath");
            }

            if (AGUtils.IsNotAndroid())
            {
                return;
            }

            if (AGDeviceInfo.SDK_INT < AGDeviceInfo.VersionCodes.KITKAT)
            {
                return;
            }

            CheckIfFileExists(imagePath);
            var uri = AndroidPersistanceUtilsInternal.GetUriFromFilePath(imagePath);

            StartCropAndSetWallpaperActivity(uri, visibleCropHint, allowBackup, which);
        }