/// <summary>
        /// Sets provided image on the provided filepath as wallpaper. 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 SetWallpaper([NotNull] string imagePath,
                                        AndroidRect visibleCropHint = null, bool allowBackup = true, WallpaperType which = WallpaperType.Unspecified)
        {
            if (imagePath == null)
            {
                throw new ArgumentNullException("imagePath");
            }

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

            CheckIfFileExists(imagePath);

            SetWallpaperBitmap(AGUtils.DecodeBitmap(imagePath), visibleCropHint, allowBackup, which);
        }
        /// <summary>
        /// Sets provided texture as wallpaper
        /// </summary>
        /// <param name="wallpaperTexture"> A texture, that will supply the wallpaper imagery.</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 SetWallpaper([NotNull] Texture2D wallpaperTexture,
                                        AndroidRect visibleCropHint = null, bool allowBackup = true, WallpaperType which = WallpaperType.Unspecified)
        {
            if (wallpaperTexture == null)
            {
                throw new ArgumentNullException("wallpaperTexture");
            }

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

            var wallpaperPath = AndroidPersistanceUtilsInternal.SaveWallpaperImageToExternalStorage(wallpaperTexture);

            if (Check.IsSdkGreaterOrEqual(AGDeviceInfo.VersionCodes.N))
            {
                SetWallpaperBitmap(AGUtils.DecodeBitmap(wallpaperPath), visibleCropHint, allowBackup, which);
                return;
            }

            SetWallpaperBitmap(AGUtils.DecodeBitmap(wallpaperPath));
        }
Ejemplo n.º 3
0
        static void SetWallpaperFromFilePath(string wallpaperPath)
        {
            var bitmapAjo = AGUtils.DecodeBitmap(wallpaperPath);

            WallpaperManager.Call("setBitmap", bitmapAjo);
        }