android-mediascanner

How To Add Media To MediaStore on Android 4.4 KitKat SD Card With Metadata

我只是一个虾纸丫 提交于 2019-12-29 04:24:32
问题 Background: In Android 4.4, Google decided that apps should not have write access to SD cards. However, apps can write to /SDCard/Android/data/App Package Name. So this is what I've done. I have written an MP3 file to /Android/data/. I then want this MP3 file to show up in Android music players. I've tried the following... sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + filePath))); and.... MediaScannerConnection.scanFile(this, new String[] { file.toString() }, new

How to make the standard music player find my files

走远了吗. 提交于 2019-12-25 01:44:26
问题 My App downloads some mp3 files to sdcard. I want to play them with other music players installed on the device. But the other music players don't automatically find my downloaded files. How can I force the MediaScanner to run so that my media files will be playable from the stock Music application? I download the files using this code public void run() { loaded = 0; try{ java.io.BufferedInputStream in = new java.io.BufferedInputStream(new java.net.URL(url).openStream()); java.io

Android - Is MediaStore ID a safe way to store information about pics/albums?

吃可爱长大的小学妹 提交于 2019-12-24 16:32:25
问题 In my app I store information about an image or an image album by storing it's MediaStore id. Later on I may have to perform operations that require these images/albums. Is the MediaStore id a safe way to keep image\album information? More specifically: 1) If an image/album whose id I have stored gets deleted, is it possible a new picture/album could take this id resulting in me using the wrong picture/album ? 2) when pictures/abums are renamed or moved ( using a file browser on the phone or

Phonegap 3.3.0 pass downloaded file cdvfile url to Media Scanner

两盒软妹~` 提交于 2019-12-24 12:11:03
问题 I managed to download a file to the local storage but I can't manage to pass it's path to the media scanner so it gets added to the gallery. I've added a plugin that does the media scanner work. The function that tries to do the trick is this one. private boolean mediaScanner(String absolutePath, CallbackContext callbackContext) throws InterruptedException, JSONException { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); String path = Uri.parse(absolutePath).getPath

Android Deleting Files MediaScannerConnection

☆樱花仙子☆ 提交于 2019-12-24 10:29:41
问题 I'm trying to delete some files or directories from the internal memory (ASUS TF101) using the commands File.delete(). However, using the Android File explorer I can see how the files are removed, but using the Windows explorer they still show there. I solved a similar issue when adding files just creating a MediaScannerConection (and using the method scanFile). Does anyone know how to solve this problem? Of course it´s not acceptable to restart the device as the final user will not like this

Phonegap - How to trigger media scanner after creating file

落爺英雄遲暮 提交于 2019-12-24 07:00:09
问题 I have the following code (this is a plugin to save a base64 as an image file on the phone) @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) { if (!action.equals("saveImage")) { return false; } try { String b64String = args.getString(0); if (b64String.startsWith("data:image")) { b64String = b64String.substring(b64String.indexOf(',') + 1); } JSONObject params = args.getJSONObject(1); //Optional parameter String filename = params.has("filename") ?

Android ACTION_MEDIA_SCANNER_SCAN_FILE not showing image until reboot?

做~自己de王妃 提交于 2019-12-23 07:50:03
问题 I am currently developing an Android Application where users take pictures which are stored in External Memory on the device then I am trying to also get the Gallery to scan the file to add the new media to the Gallery however this does not seem to update until the device reboots. The code I am using is as follows: Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); File f = new File(mCurrentPhotoPath); Log.v("INFO", mCurrentPhotoPath.toString()); Uri contentUri = Uri

Refreshing the thumbnail using MediaScanner

瘦欲@ 提交于 2019-12-22 01:32:04
问题 When I save an image to new location and then use MediaScanner to refresh the gallery then everything is fine - thumbnails and images are refreshed well. But when I save an image to EXISTING location and then use MediaScanner - then only 'new' thumbnail isnt refreshed. (even though file is overwritten). How to solve it? Here is my code : File file = new File(SDCARD_PATH, filename); try { FileOutputStream out = new FileOutputStream(file); bmp.compress(format, BEST_IMAGE_QUALITY, out); }catch

How to refresh Android's MediaStore upon photo deletion

耗尽温柔 提交于 2019-12-21 13:43:21
问题 Question: how to make the media store to refresh its entry of a DELETED file? After deleting a photo in code from the external storage, I still see a slot for the deleted photo in the gallery - blank photo. It seems that the gallery reflects the media store and the deleted photo is found in the media store until the phone is restarted or generally - until the media is rescanned. Trying to scan the deleted file did not help scanning deleted files (works just for new or existing files):

How to refresh Gallery after deleting image from SDCard

拥有回忆 提交于 2019-12-18 13:24:42
问题 When deleting the images on Android’s SD Card, sometime the images are correctly removed but in the gallery still remain a preview of the removed image. When tapping on it, it is loaded as a black image. To resolve it, you need to run MediaScanner. But this code won't work and still the preview of review image remain in the Gallery. Anyone knows how to resolve this. Uri contentUri = Uri.fromFile(file); Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,contentUri);