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. Managing view's refresh delay and soft keyboard

I repost here what I've already written on the Android Developer group
cause it fit better here.

Hi to everyone. I start trying out some stuff with Android from few
days so there's lot I don't know but I hope not to sound too stupid.
Here are the first problems I'm facing

1) I have a ListView where each item is made of two icon (on the left
and right side) and an EditText, disabled, in the middle. I have a
button to add new element to the lists and what I want to happen is
that clicking on it a new lne appears in the ListView with the focus
on the EditText so that the user can type a label for the object.
What I tried to do when the button is clicked is:
- add a new object to the array binded to the ListView;
- notify the array adapter that a change as occoured in the data
- retrieve the view object for the last child added to the ListView
- set the focus on the EditText
The problem is that between the call of notifyDataSetChanged() and the
 creation of a new child in the ListView there's a delay and so I'm
not able to get the new created view in the click handler. What's the
best way to handle it?

2) Considering the same scenario when I give focus to the EditText I
see the cursor for editing the field value but the soft keyboard
doens't appear. That's perfect on a device with an hard keyboard, but
what would happen if the device doesn't have one?
The other thing I find weird is that when I tap the EditText the
keyboard finally appears but the field lost the focus so I can type
whatever I want but nothing appear in the field. This latest thing
seems to be in some way related to the fact the EditText is part of
the layout used to display each item in the list. Any idea on how to
solve it?

That's all, I hope it was fairly clear and to get some help.
Thank you for reading

Andrea

--~--~---------~--~----~------------~-------~--~----~

2. Dialo

Hello everybody,
i just begin with the SDK so I play around but I'm stuck with a really
simple Dialog.show() ...
It maybe is because it'es really late or something but here my code :

public class entry extends Activity {
        static final int CREATE_DIALOG = 0;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.entry);
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();

        inflater.inflate(R.menu.menu_bottom, menu);
        return true;
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
                case R.id.create:
                    this.showDialog(CREATE_DIALOG);

                return true;
            }

            return false;
    }

        protected Dialog onCreateDialog(int id) {
                Dialog dialog;

                switch(id) {
                    case CREATE_DIALOG:
                        dialog = new Dialog(this.getApplicationContext());

                        dialog.setContentView(R.layout.create_dialog);
                        dialog.setTitle("Pwals");
                    break;

                    default:
                        dialog = null;
                    break;
            }

            return dialog;
        }
}

The XMLs are just as simple as this code and they are running good
It crash when I it the menu button "create"
What I haven't understand :s ?

Thx for your answer

--~--~---------~--~----~------------~-------~--~----~

3. Problem running HelloWorld (or anny sample application)

4. ADT Plugin for Eclipse Source Code

5. How to add a keyboard localisation

6. Fellow Android Developers...

7. contacts is VERY SLOW after I import my 4,000+ contacts on G1 (with mobile no, notes, work phones etc)...