I am trying to change the Android wallpaper using code. I'm using the wallpaper manager class, but no one is strong. I have one in the / Drable Directory. PGG image used. I'm getting an error that says, "the type of expected resource crude" when I run the application (when that method runs), it crashes. I should actually be a victim of a stupid mistake after the user taps a button, the change of method is run (). Here's my code:
Public Zero ConversionWalter (see view) {try {WallpaperManager wallpaperManager = WallpaperManager.getInstance (getApplicationContext ()); WallpaperManager.setResource (R.drawable.material_wallpaper); String Success Message = "Wallpaper Changes"; Toast. Make Text (This, Success Message, Toast. LNGHORART) Show (); } Hold (IOException e) {e.printStackTrace (); String fails = "operation failed"; Toast. Make text (this, failed message, toast. LNGHHRART). Show (); }}
Edit: There is no "raw" folder in my / res / directory.
If you want to be with drawable, then you can change the resource to a bitmap and then You can set it as wallpaper using setBitmap (bitmap_bitmap)
(see).
WallpaperManager WallpaperMagger = WallpaperManager.Testance (GetActivity.) GetApplicationContext ()); Bitmap bitmap = bitApplication (getActivity). GetResources (), RDRA. WallpaperManager.setBitmap (bitmap);
No comments:
Post a Comment