Abhishek Batra
Abhishek Batra

Reputation: 1599

Android set wallpaper using intent

I am trying to make wallpaper application. I am able to set the wallpaper using wallpaper manager. But what i want is when i click a button a new intent should open which should be the default way of setting wallpaper of the device. (the screen we get when we try to set an image form gallery as wallpaper, where we can select the area of the image etc etc). I have goggled but couldn't find any solution.

Upvotes: 4

Views: 8620

Answers (3)

Beppe
Beppe

Reputation: 201

I know its late but for someone to wants, its works for me.

final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
    final Drawable wallpaperDrawable = wallpaperManager.getDrawable();
    try {
        wallpaperManager.setBitmap(yourImageView.getDrawingCache());
        finish();
    } catch (IOException e) {
        e.printStackTrace();
    }

Upvotes: 0

DagW
DagW

Reputation: 955

This is a better solution, wher you dont have to specify a target app;

Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
startActivity(Intent.createChooser(intent, "Select Wallpaper"));

Upvotes: 1

ozbek
ozbek

Reputation: 21183

Use "android.intent.action.SET_WALLPAPER" + set component/class of your wallpaper application so that the Intent would be handled by your app.

For example, that'd look like as follows for AOSP built-in wallpaper application:

Intent intent = new Intent("android.intent.action.SET_WALLPAPER");
// Change the following line with that of your own app
intent.setClassName("com.android.launcher", "com.android.launcher2.WallpaperChooser");
try {
    startActivity(intent);
} catch (ActivityNotFoundException e) {
    Log.wtf(TAG, "No activity found to handle " + + intent.toString());
}

Upvotes: 0

Related Questions