Here's an update on where I am with this. I have to say it's pretty
"hackish" and I'm not proud of it but it works, sorta.
I created a Preference in my Settings dialog to choose the background. From
the callback I call 'startActivityForResult' with
the Intent.ACTION_SET_WALLPAPER.
This launches the default wallpaper chooser allowing the user to select
whatever they want for the wallpaper, with the caveat that the "Live
Wallpapers" shows up also, which I don't want.
In the 'onActivityResult' callback i check for RESUT_OK and do the
following:
- Get an instance of the wallpaper manager.
- Get the drawable from it.
- Turn it into a BitmapDrawable and write it to a private file (for
persistence) also storing it in a variable.
- During my regular draw function I draw that to the canvas and then draw my
overlay.
On startup of my wallpaper I check if the file exists. If it does then I
read it into my bitmap variable and continue as normal.
If it doesn't exist then I get the wallpaper drawable and do the same things
as above (file, variable).
This works wonderfully for most situations. But it breaks horribly when the
user selects a live wallpaper in my settings dialog.
In the Emulator things keep working. My 'onActivityResult' gets a
RESULT_CANCEL event and nothing changes for me. I'm able to back out of the
settings screen and continue no problem.
On my device however (HTC Desire w/ 2.1) it crashes the phone when I select
a live wallpaper from within my settings.
Why the discrepancy between the two? The only difference that I can tell
between the two is that my device has more live wallpapers installed.
What can I do?
Can I detect that a live wallpaper was selected and handle it differently?
I didn't debug the app on my phone so I don't know exactly what was
happening.
My exact call to start the activity looks like this:
private void startWallpaper() {
final Intent pickWallpaper = new Intent(Intent.ACTION_SET_WALLPAPER);
startActivityForResult(Intent.createChooser(pickWallpaper,
getString(R.string.rain_background)),REQUEST_PICK_BACKGROUND);
}
The Live wallpaper chooser has two intents; ACTION_SET_WALLPAPER
and ACTION_LIVE_WALLPAPER_CHOOSER. Is there a way, when I call
Intent.createChooser to filter out based on an intent even though an item
matches another intent?
If not then Google seriously needs to give us this.
Not sure what to do next.
I'm so close I can feel it.
Joel
On Thu, Sep 9, 2010 at 2:11 PM, JoelDuggan <[email protected]> wrote:
> Hello all,
>
> I've asked this question twice already but it didn't seem to get
> posted. I don't know if it just takes a while for the moderators to
> approve or if it got lost so I'll try again.
>
> I'm writing a live wallpaper that creates an effect over a
> background. I want the user to be able to choose the background from
> any of the system wallpapers and camera photos. What I would like is
> for the user to be able to press a button in the Settings menu, have
> the list of options show up just like setting the wallpaper from the
> home screen, minus the Live Wallpapers options. Once the user
> navigates the choices and picks an actually image I would load it to
> my canvas.
>
> How do I do this?
>
> I can't find an API anywhere for getting a list of wallpapers.
>
> I've been able to come up with a list of wallpaper providers using
> Intents. I then get a list of live wallpaper providers also using
> Intents and remove those from my first list. The gives me a list of
> wallpaper providers that are not live.
>
> Now what? Are there other ways to do this that I'm missing?
>
> Please help.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en