android - Saving images to my own directory? image to fit Screen Size? -


i implementing wallpaper app. has lot of images of 100.

1) want save images in gallery seperate folder.
2) when set wallpaper size image zooms ,how fit screen size?

i used

 mediastore.images.media.insertimage(getcontentresolver(), yourbitmap, yourtitle     ,yourdescription);  

it stores in folder named camera, need own directoy name.

i tried many things , many searches fitting image screen size

i used display metrics

bitmap bmap2 =bitmapfactory.decodestream(getresources().openrawresource(r.drawable.paper));    displaymetrics metrics = new displaymetrics();  getwindowmanager().getdefaultdisplay().getmetrics(metrics); int height = metrics.heightpixels;  int width = metrics.widthpixels; bitmap bitmap = bitmap.createscaledbitmap(bmap2, width, height, true);   wallpapermanager wallpapermanager = wallpapermanager.getinstance(mainactivity.this);  try {  wallpapermanager.setbitmap(bitmap);  } catch (ioexception e) {  e.printstacktrace();  }   

and other dispaly metrics none worked.. having many images used switch case ,

i using horizontal scroll view images present when image clicked here.
goes main view , below have set wallpaper button..!!

my code...

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      setcontentview(r.layout.activity_main);      display = (imageview) findviewbyid(r.id.imageview1);     imageview image1 = (imageview) findviewbyid(r.id.imageview11);     imageview image2 = (imageview) findviewbyid(r.id.imageview2);     imageview image3 = (imageview) findviewbyid(r.id.imageview3);     imageview image4 = (imageview) findviewbyid(r.id.imageview4);     imageview image5 = (imageview) findviewbyid(r.id.imageview5);     imageview image6 = (imageview) findviewbyid(r.id.imageview6);      imageview image7 = (imageview) findviewbyid(r.id.imageview7);     imageview image8 = (imageview) findviewbyid(r.id.imageview8);     imageview image9 = (imageview) findviewbyid(r.id.imageview9); 

display main image view
image1 , image2 .... images in horizontal scroll view...!!

i 've used switch case setting horizontzal view images main image view ..

public void onclick(view v) {      switch (v.getid()) {       case r.id.imageview11:         wallpaper.setenabled(true);          display.setimageresource(r.drawable.w1);         tophone = r.drawable.w1;          break;     case r.id.imageview2:         wallpaper.setenabled(true);          display.setimageresource(r.drawable.w2);         tophone = r.drawable.w2;          break;     case r.id.imageview3:         wallpaper.setenabled(true);         display.setimageresource(r.drawable.w3);         tophone = r.drawable.w3;          break; 

and when set wall paper clicked.!

case r.id.button1:          img = bitmapfactory.decodestream(getresources().openrawresource(                 tophone));         try {             wallpapermanager.getinstance(getapplicationcontext())                     .setbitmap(img);             toast showtoast = toast.maketext(getapplicationcontext(),                     "wallpaper set", toast.length_short);             showtoast.show();             break;          } catch (exception m) {          }         img = bitmapfactory.decodestream(getresources().openrawresource(                 tophone));         try {             wallpapermanager.getinstance(getapplicationcontext())                     .setbitmap(img);             toast showtoast = toast.maketext(getapplicationcontext(),                     "wallpaper set", toast.length_short);             showtoast.show();             break;          } catch (exception m) {          } 

can please me..
've been trying since week these 2 solutions.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -