android - Wallpaper not properly fit on Samsung devices -
i want set wallpaper through app device problem following approach work moto, sony, micromax not fit any samsung device samsung s3, samsung duos, tab etc, in these devices wallpaper zoom see in screenshots.
please guide me solve problem.
private void setmywallpaper() { wallpapermanager mywallpapermanager = wallpapermanager .getinstance(getapplicationcontext()); displaymetrics metrics = new displaymetrics(); getwindowmanager().getdefaultdisplay().getmetrics(metrics); // height , width of screen int height = metrics.heightpixels; int width = metrics.widthpixels; drawable drawable = null; if (who.equals("color")) drawable = getresources().getdrawable(colorwallpaper[i]); else drawable = getresources().getdrawable(graywallpaper[i]); bitmap bitmap = ((bitmapdrawable) drawable).getbitmap(); bitmap wallpaper = bitmap.createscaledbitmap(bitmap, width, height,true); mywallpapermanager.suggestdesireddimensions(width, height); try { mywallpapermanager.setbitmap(wallpaper); log.i("wall", "wallpaper set "); } catch (ioexception e) { e.printstacktrace(); } }
i solve problem using call intent in place of wallpapermanager
this:
//load file
file file = new file(getgallerypath()); if ( file.exists()) { intent intent = new intent(intent.action_attach_data); intent.addcategory(intent.category_default); intent.setdataandtype(uri.fromfile(file), "image/jpeg"); intent.putextra("mimetype", "image/jpeg"); this.startactivity(intent.createchooser(intent, "set as:")); } else { log.d("test", "file not exixts."); }
// method getting image path
private static string getgallerypath() { return environment.getexternalstoragedirectory() + "/" + environment.directory_dcim + "/myimages/img-20160326-wa0083.jpg"; }
Comments
Post a Comment