What should I do to call Native Wallpaper picker to set Wallpaper for my layout in android?
Asked Answered
A

2

6

That is my question. For them who dont know what i am asking, I want to make this menu to appear in my app http://db.tt/GQX9GBYF . The thing is that I Dont have any idea how to do it. I think that I have to create an intent, from it obtain image path and then, set it as background. But i dont know the exact way to do it...

Please, anyone could post me an example, please???? ;)

I have to say that I managed to do it by launching native gallery app, but I want to set live wallpapers too

Arian answered 27/5, 2012 at 11:10 Comment(0)
U
6

You Intent.ACTION_SET_WALLPAPER for starting ContaxtMenu for Selecting Wallpaper as:

Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
startActivity(Intent.createChooser(intent, "Select Wallpaper"));
Urena answered 27/5, 2012 at 11:29 Comment(3)
ok it worked, but it sets launcher background, and I only want to set wallpaper for my app... any idea?? THANKS A LOT!!Arian
myLayout.setBackgroundDrawable(getWallpaper()); gets the wallpaper and sets it for your layoutSchoolfellow
Heads up: if you just pass the intent instead of calling Intent.createChooser, the default app will start (in my case that was the "Live Wallpaper"-chooser)Rhodonite
C
1

Currently I'm working on the same thing. The accepted answer is correct but if you want to use wallpaper as your app's background, then you have to use Wallpaper theme & call the Intent.Action_Set_Wallpaper to pick wallpaper.

public void onCreate(Bundle savedInstanceState) {

 Activity.this.setTheme(android.R.style.Theme_Wallpaper);

super.onCreate(savedInstanceState);
setContentView(/*some layout*/);
}

//on button click

Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
startActivity(Intent.createChooser(intent, "Select Wallpaper"));
Calvo answered 16/12, 2013 at 16:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.