java - Retrieving bitmap from internal memory fails on newer android versions -


I am developing an Android project with Google Maps and has a custom image for markers in Google Map. But instead of downloading it, the images are downloaded to the internal memory for the first time, for the first time the marker images are downloaded from the second time, I check that the images have been downloaded and then they are obtained from the storage.

But the code is my phone (Android version 2.6.3), but when I tried to get the code reverse tap to reverse the bitmap image downloaded on new devices (Android 4 and above).

has downloaded the images or not, the code to check it:

  public void Cheksnketmaijej (available) {path_file = MainActivity.this.getFilesDir (). GetAbsolutePath (); For (Int i = 0; i & lt; catprearr.size (); i ++) {file = new File (Pth_fail + file. Separator + Katpirrarkget (i) + ". Png"); If (file.exists ()) {} else {DownloadFile (URL_image + catprearr.get (i) + 'png. ", Path_file + File.separator + catprearr.get (i) +' png."); }} Setvaluesonmap (); }  

Code for downloading pictures:

  Public Zero DownloadFile (string path, string filepath) {try {url = url = new URL (path) ; URLConnection ucon = url.openConnection (); Ucon.setReadTimeout (5000); Ucon.setConnectTimeout (10000); InputStream = ucon.getInputStream (); BufferedInputStream inStream = New BufferedInputStream (is, 1024 * 5); File file = new file (file path); File.createNewFile (); FileOutputStream Outstream = New FileOutputStream (file); Byte [] buff = new byte [5 * 1024]; Int len; While ((lane = instream. Read (fond)) = -1) {outstream.write (buff, 0, lane); } Outstream.flush (); OutStream.close (); InStream.close (); } Hold (exception e) {e.printStackTrace (); }}  

Code to set markers:

  public zero setvaluesonmap () {(int i = 0; I & lt; list.size ); I ++) {final store_data s = list.get (i); Bitmap obj = getImageBitmap (main activity. This, serial + ".png"); Obj = bitmap.createScaledBitmap (obj, 68, 62, false); Iv_category_logo.setImageBitmap (obj); GoogleMapkaddMarker (New MarkerOptions (). Title (s.store_name) .icon (BitmapDescriptorFactory.fromBitmap (createDrawableFromView (MainActivity.this, custom_layout))) .position (New LatLng (Double.parseDouble (s.store_latitude), Double.parseDouble (S.store_longitude)))); }}  

Code for retrieving downloaded image: This is a disturbing code: bitmap returns empty space on new devices

  bitmap getImageBitmap (reference reference, string name) {try file {} FileInputStream fis = context.openFileInput (name); // file file = new file ("file", name); File myFile = new file (path_file + File.Sseparator + name); Byte [mybytearray = new byte [(int) myFile.length ()]; FileInputStream fis = New FileInputStream (myFile); BufferedInputStream bis = new BufferedInputStream (fis); Bitmap b = bitmapfinder Ecodestream (FIS); //fis.close (); Return b; } Hold (exception e) {return tap; }}  

Why it works fine on older devices, but does not work on new devices.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -