/*** Convert a View object to bitmap*/ PrivateBitmap Getviewbitmap (Mapview v) {v.clearfocus (); V.setpressed (false); //you can draw the cache and return False . BooleanWillnotcache =v.willnotcachedrawing (); V.setwillnotcachedrawing (false); intcolor =V.getdrawingcachebackgroundcolor (); V.setdrawingcachebackgroundcolor (0); if(Color! = 0) {V.destroydrawingcache (); } v.builddrawingcache (); Bitmap Cachebitmap=NULL; while(Cachebitmap = =NULL) {Cachebitmap= V.getdrawingmapcache (0, 0, V.getwidth (), V.getheight ()); } Bitmap Bitmap=Bitmap.createbitmap (CACHEBITMAP); //Restore The ViewV.destroydrawingcache (); V.setwillnotcachedrawing (Willnotcache); V.setdrawingcachebackgroundcolor (color); returnbitmap; } Public voidsavemybitmap (String Bitname,bitmap mbitmap) {string FileName= This. Getinnersdcardpath () + "/" + Bitname + ". png"; ShowMessage (FileName); File F=NewFile (FileName); Try{f.createnewfile (); } Catch(IOException e) {//TODO auto-generated Catch blockLOG.E ("Error saving" +filename+ "Picture:" + e.tostring (), "Error saving" +filename+ "Picture:" +e.tostring ()); } FileOutputStream FOut=NULL; Try{FOut=NewFileOutputStream (f); } Catch(FileNotFoundException e) {e.printstacktrace (); } mbitmap.compress (Bitmap.CompressFormat.PNG,100, FOut); Try{Fout.flush (); } Catch(IOException e) {e.printstacktrace (); } Try{fout.close (); } Catch(IOException e) {e.printstacktrace (); } } //Zoom Out Private classButtonnexitclicklistenerImplementsView.onclicklistener { Public voidOnClick (View v) {//showmessage ("Ok1");Bitmap bitmap=Getviewbitmap (Mapview); //showmessage ("Ok2");Savemybitmap ("YL", bitmap); //showmessage ("Ok3");bitmap.recycle (); ShowMessage ("Saved successfully"); } }
Andriod ArcGIS Save Mapview as a picture