Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- adb shell service call activity 42 s16 com.android.systemui
- adb shell am startservice -n com.android.systemui/.SystemUIService
- private void refreshWallpaper()
- {
- try
- {
- WallpaperManager wallpaperManager = WallpaperManager.getInstance(context);
- WallpaperInfo wallpaperInfo = wallpaperManager.getWallpaperInfo();
- // wallpaperInfo is null if a static wallpaper is selected and
- // is not null for live wallpaper & video wallpaper.
- if (wallpaperInfo == null)
- {
- // get the existing wallpaper drawable
- Drawable wallpaper = wallpaperManager.peekDrawable();
- // convert it to a bitmap
- Bitmap wallpaperBitmap = drawableToBitmap(wallpaper);
- // reset the bitmap to the current wallpaper
- wallpaperManager.setBitmap(wallpaperBitmap);
- }
- }
- catch (Exception e)
- {
- // TODO: Handle exception as needed
- e.printStackTrace();
- }
- }
- private static Bitmap drawableToBitmap(Drawable drawable)
- {
- if (drawable instanceof BitmapDrawable)
- {
- return ((BitmapDrawable) drawable).getBitmap();
- }
- Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Config.ARGB_8888);
- Canvas canvas = new Canvas(bitmap);
- drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
- drawable.draw(canvas);
- return bitmap;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement