WallpaperManager.sendWallpaperCommand() doesn't work?

by John Lussmyer » Thu, 13 Jan 2011 23:56:27 GMT


Sponsored Links
 I just noticed this method, and since I have a Live Wallpaper I've written,
I decided it might be fun to use this.

So in one of my apps, it checks to see if my Live Wallpaper is the current
wallpaper, and sends a command if it is.
I get no errors in the log, but the wallpaper never receives the command.
(There are logging statements in the onCommand() handler.)

Is there some permission or other settings I have to enable to get this to
work?

-- 



Re: WallpaperManager.sendWallpaperCommand() doesn't work?

by Dianne Hackborn » Fri, 14 Jan 2011 04:37:02 GMT


 You must be the current foreground activity sitting on top of the wallpaper
to use the command.








-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 


Sponsored Links


Re: WallpaperManager.sendWallpaperCommand() doesn't work?

by John Lussmyer » Fri, 14 Jan 2011 06:10:22 GMT


 My app is the one the user is working with, and the command is sent during
the onOptionsItemSelected() processing.





-- 



Re: WallpaperManager.sendWallpaperCommand() doesn't work?

by John Lussmyer » Fri, 14 Jan 2011 08:39:37 GMT


 Hmm, question on that.  By "sitting on top of the wallpaper", do you mean an
app that leaves the wallpaper partially visible? (like the desktop)






-- 



Re: WallpaperManager.sendWallpaperCommand() doesn't work?

by Dianne Hackborn » Fri, 14 Jan 2011 08:56:16 GMT


 Yes you must be showing the wallpaper, such as by settings your theme to
Theme.Wallpaper.









-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 



Re: WallpaperManager.sendWallpaperCommand() doesn't work?

by John Lussmyer » Fri, 14 Jan 2011 09:37:24 GMT


 It is showing.  It's the active wallpaper.
I then launch my app, and select the menu item that sends the wallpaper
command.  (Note that this checks to see that the active wallpaper IS the one
it's expecting.)
The log shows my app sending the command, but the wallpaper never receives
it.








-- 



Re: WallpaperManager.sendWallpaperCommand() doesn't work?

by Dianne Hackborn » Fri, 14 Jan 2011 13:25:32 GMT


 Hm, well there isn't enough information for me to help much more.  All I can
say is that I know this works, for example it is how the launcher tells the
wallpaper you have dropped an icon which results in things like the nexus
wallpaper to react with its flying nexi from that point.











-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 



Re: WallpaperManager.sendWallpaperCommand() doesn't work?

by String » Fri, 14 Jan 2011 21:38:33 GMT


 I think you're misunderstanding Dianne's posts.

When most people (including you, I think) talk about "the wallpaper", they 
mean the one on the home screen. The app that's running that wallpaper is 
the Launcher, and so the Launcher is the only app which can send commands to 
"the wallpaper" as defined above.

Separate from this, it's also possible - though rare - for other apps to use 
wallpapers as their own background. If your app is doing this, then it can 
send commands to THAT wallpaper.

In no circumstance, AFAIK, can an app which isn't the Launcher (or a 
replacement) send commands to "the wallpaper" running on the device's home 
screen. The documentation is not at all clear on this, but I've been down 
this road in the past. If you want to ping your own wallpaper (running on 
the home screen) from your app, one method which does work is to fire off a 
custom intent, and listen for that intent in your WallpaperService.

String


-- 



Re: WallpaperManager.sendWallpaperCommand() doesn't work?

by John Lussmyer » Fri, 14 Jan 2011 23:50:34 GMT


 Thanks for the clarification.
So the statement "Finally, applications can send arbitrary commands to the
live wallpaper." is just plain wrong in the documentation at:
 http://developer.android.com/resources/articles/live-wallpapers.html 





-- 



Re: WallpaperManager.sendWallpaperCommand() doesn't work?

by Dianne Hackborn » Sat, 15 Jan 2011 01:39:37 GMT


 No, that is not true.  Launcher does not own the wallpaper.  It uses
Theme.Wallpaper to have itself displayed on top of the wallpaper -- that is,
its own window has translucency so you can see the wallpaper surface (owned
by the current wallpaper) behind it.  During this time, it is allowed to
interact with the wallpaper (change its offset, send commands, etc) only
because it is currently the app on top of the wallpaper.

If your own app is running on top of the wallpaper in the same way, then you
too can interact with it.  If not, you can't.  If this wasn't the cause, no
launcher replacements would be able to interact with the wallpaper either.







-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 



Re: WallpaperManager.sendWallpaperCommand() doesn't work?

by John Lussmyer » Sat, 15 Jan 2011 02:02:32 GMT


 Thanks.  Another point where the documentation could use some updating.





-- 



Other Threads

1. Market enabler

Bro n sis,
Mo tanya cara pake market enabler, karena tiap kali dipilih provider nya
selalu keluar "we got a problem houston :( "  mohon pencerahannya.

Salam

sent from android hero,  powered by indosat

--~--~---------~--~----~------------~-------~--~----~
Google Groups "
-~----------~----~----~----~------~----~------~--~---

2. Aplikasi Piala Asia Qatar

mantappp mas, menuju tekape..






-- 
===============
"

3. App Add-on

4. Stolen Android phone

5. DNS WHOIS query support

6. How to stop ADB server

7. How to access mail ?