How to make a button set a photo to the homescreen? (Android Sudio) -


okay, creating wallpaper app android platform, , have xml set perfectly, cannot figure out procedure set selected photo home screen/lock screen via button. input appreciated greatly.

try this:

add code in manifest.xml

 <uses-permission android:name="android.permission.set_wallpaper"/> 

and can set background code:

button buttonsetwallpaper = (button)findviewbyid(r.id.set);             imageview imagepreview = (imageview)findviewbyid(r.id.preview);             imagepreview.setimageresource(r.drawable.five);              buttonsetwallpaper.setonclicklistener(new button.onclicklistener(){             @override             public void onclick(view arg0) {             // todo auto-generated method stub             wallpapermanager mywallpapermanager              = wallpapermanager.getinstance(getapplicationcontext());             try {                 mywallpapermanager.setresource(r.drawable.five);             } catch (ioexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }             }}); 

it work.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -