Imageview to bitmap
Bitmap bitmap = (bitmapdrawable) IMG. getdrawable (). getbitmap ();
Bitmap bitmap = (bitmapdrawable) IMG. getdrawable (). getbitmap ();
@ Overridepublic Boolean onlongclick (view v) {If (v. GETID () = R. id. listener_imageview1) {// set the desktop background with a persistent click // 1. try {listenerdemoactivity. this. clearwallpaper (); // listenerdemoactivity. this. setwallpaper (getapplicationcontext (). getresources (). openrawresource (R. drawable. pic1); textview2.settext ("the desktop background is set successfully! "); Bitmap bitmap = (bitmapdrawable) IMG. getdrawable ()). getbitmap (); listenerdemoactivity. this. setwallpaper (Bitmap);} catch (ioexception e) {textview2.settext ("failed to set the mobile desktop background !! "); E. printstacktrace () ;}return false ;}}
Imageview and bitmap conversion, instance: sets the current view image as the desktop background