Opening a dialog when an Android live wallpaper is touched -


i’d open dialog box simple information on when live wallpaper tapped. overriding oncommand in android live wallpaper, , adding custom dialog straight out of android docs (with layout info_dialog.xml not shown):

@override public bundle oncommand (string action, int x, int y, int z, bundle extras, boolean resultrequested) {  system.out.println(action);    context mcontext = getapplicationcontext();  dialog dialog = new dialog(mcontext);   dialog.setcontentview(r.layout.info_dialog);  dialog.settitle("custom dialog");   textview text = (textview) dialog.findviewbyid(r.id.text);  text.settext("hello, custom dialog!");   dialog.show();   return null }     

just generates exception:

12-02 07:14:40.880: error/androidruntime(295): android.view.windowmanager$badtokenexception: unable add window -- token null not application 12-02 07:14:40.880: error/androidruntime(295):     @ android.view.viewroot.setview(viewroot.java:509)  12-02 07:14:40.880: error/androidruntime(295):     @ android.view.windowmanagerimpl.addview(windowmanagerimpl.java:177)  12-02 07:14:40.880: error/androidruntime(295):     @ android.view.windowmanagerimpl.addview(windowmanagerimpl.java:91)  12-02 07:14:40.880: error/androidruntime(295):     @ android.app.dialog.show(dialog.java:241) 

i’m assuming because i’m trying raise dialog wallpaperservice rather activity. overriding wallpaperservice.engine’s ontouchevent method gets same result.

does mean need spin separate activity host dialog? or triggering dialog live wallpaper not possible?

does mean need spin separate activity host dialog?

yes. or, better yet, use dialog-themed activity.

personally, if expecting whole live wallpaper, expect whole bunch of one-star ratings on market, suspect users irritated when activity/dialog keeps popping because mis-tap on home screen.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -