I noticed something odd with the way Galaxy Nexus handles photos and file directories. I create them but Android (4.2.2) does not know they exist until you reboot. Well at least on my Nexus 4. I am creating an app and when taking a photo and storing it in Pictures it does not show on Gallery or even show up on my file explorer when you connect your phone to the computer. But when using a file explorer on the phone it finds it. When I reboot my phone it also appears. Is this specific to stock Android? I am making this assumption as it does not happen on my friend's Galaxy S3. So leading to my actual question, is there a way to force Android to re-index the files to update the info without rebooting?
add this code after save photos in SD gallery..
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + Environment.getExternalStorageDirectory())));
use
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + Environment.getExternalStorageDirectory())));
hope you have used this:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
来源:https://stackoverflow.com/questions/16008419/how-to-force-android-to-re-index-all-the-photos-on-the-phone