Skip to content

Instantly share code, notes, and snippets.

@vtthach
Created July 20, 2017 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vtthach/b65ca8e1c574f8786e1c6e561470b5aa to your computer and use it in GitHub Desktop.
Save vtthach/b65ca8e1c574f8786e1c6e561470b5aa to your computer and use it in GitHub Desktop.
Notify gallery insert an image with path
// 其次把文件插入到系统图库
try {
MediaStore.Images.Media.insertImage(view.getMyContext().getContentResolver(), file.getAbsolutePath(), fileName, null);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
// 最后通知图库更新
view.getMyContext().sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + file.getPath())));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment