Maybe we all know when we download the image to the Android phone, and then call the system library to open the picture, prompting "cannot find the specified item".
That's because the images we've inserted haven't been updated, so just plug the pictures into the system gallery and then the clockwork broadcast will be OK.
/** * Picture inserted into the system album, solve the system library cannot open picture problem * /public static void Insertimagetosystemgallery (context context, String FilePath, Bitmap Bitmap) { MediaStore.Images.Media.insertImage (Context.getcontentresolver (), Bitmap, "", ""); Intent Intent = new Intent (intent.action_media_scanner_scan_file); Uri uri = uri.fromfile (new File (FilePath)); Intent.setdata (URI); Context.sendbroadcast (intent); }
Attach the method to get the picture path:
Gets the absolute path of the picture private String getfilepathbycontentresolver (context context, Uri Uri) {if (null = = URI) {return null;} Cursor C = context.getcontentresolver (). Query (URI, NULL, NULL, NULL, or null); String FilePath = null; if (null = = c) { throw new IllegalArgumentException ( "Query on" + URI + "returns null result.") ; try { if (c.getcount ()! = 1) | |!c.movetofirst ()) { } else { FilePath = c.getstring ( c.getcolumnindex Orthrow (Mediacolumns.data)); } } finally { c.close (); } return filePath; }
Android image download to local, System gallery does not display