java - Android, set Background Stretches or zooms in but never correct -
i have been trying set background of phone using android wallpaper app made. every time press "set background" stretches image.
here code using
btnsetwallpaper.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { wallpapermanager wmanager; try { // bitmap bitmap = ((bitmapdrawable)imageview1.getdrawable()).getbitmap(); wmanager = wallpapermanager.getinstance(view.getcontext().getapplicationcontext()); display display = getwindowmanager().getdefaultdisplay(); point size = new point(); display.getsize(size); int fullwidth = size.x; int fullheight = size.y; //int fullwidth = wmanager.getdesiredminimumwidth(); //int fullheight = wmanager.getdesiredminimumheight(); log.d("debug", integer.tostring(fullwidth)); log.d("debug", integer.tostring(fullheight)); bitmap bitmapresized = bitmap.createscaledbitmap(bmpwallpaper, fullwidth * 2, fullheight, true); wmanager.setbitmap(bitmapresized); } catch (ioexception e) { e.printstacktrace(); } core.makenotification(view.getcontext(), "mynotification", "your wallpaper has been set, enjoy!"); core.makealert(view.getcontext(), "wallpaper set", "your wallpaper has been set, enjoy!"); } });
okay after comment bakrionfire searched around on link gave me, after combining bit of code code described there i've found solution!
btnsetwallpaper.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { try { wallpapermanager wmanager = wallpapermanager.getinstance(view.getcontext()); display display = getwindowmanager().getdefaultdisplay(); point size = new point(); display.getsize(size); int fullwidth = size.x; int fullheight = size.y; //int fullwidth = wmanager.getdesiredminimumwidth(); //int fullheight = wmanager.getdesiredminimumheight(); log.d("debug", integer.tostring(fullwidth)); log.d("debug", integer.tostring(fullheight)); bitmap bitmapresized = bitmap.createscaledbitmap(bmpwallpaper, fullwidth, fullheight, true); wmanager.suggestdesireddimensions(bitmapresized.getwidth(), bitmapresized.getheight()); wmanager.setbitmap(bitmapresized); } catch (ioexception e) { e.printstacktrace(); } core.makenotification(view.getcontext(), "mcpaper", "your wallpaper has been set, enjoy!"); core.makealert(view.getcontext(), "wallpaper set", "your wallpaper has been set, enjoy!"); } });
i hope in future people out because i've spend long time on this. enjoy
Comments
Post a Comment