KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I always found the following answer for my Question: context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); but it do not work on my System (Nexus4 Android 4. ...) I can create a File and add it to the Media-DB whith this code Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri contentUri = Uri.fromFile(file); mediaScanIntent.setData(contentUri); context.sendBroadcast(mediaScanIntent); Where "file" is the new image-file i want to add. after deleting the File I try to refresch the gallery by Intent intent = new Intent(Intent.ACTION_MEDIA_MOUNTED); Uri contentUri = Uri.parse("file://" + Environment.getExternalStorageDirectory()); intent.setData(contentUri); context.sendBroadcast(intent); or context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); but there are still empty placeholder in the Galery. I do not know why?... To be on the safe side I add too my Activity in the AndroidManifest.xml <intent-filter> <action android:name="android.intent.action.MEDIA_MOUNTED" /> <data android:scheme="file" /> </intent-filter> but the result is the same. Any idea to solve the problem?
Tags (comma-separated)
Save Edits
Cancel