android-mediascanner

UNIQUE constraint failed when trying to share video via intent

不羁的心 提交于 2019-12-08 19:58:27
Hey I'm trying to develop an app which would allow users to share video files. Whenever I try to share the same video file for the second time I get constraint failed error 11-21 20:46:47.103 1076-4528/? E/SQLiteDatabase﹕ Error inserting bucket_id=-1634214109 date_modified=1448138795 datetaken=1448138795000 bucket_display_name=.estrongs parent=894 format=12299 storage_id=131073 media_type=3 mime_type=video/mp4 _size=1235266 title=video1 _data=/storage/sdcard1/.estrongs/video1.mp4 date_added=1448138807 _display_name=video1.mp4 android.database.sqlite.SQLiteConstraintException: UNIQUE constraint

UNIQUE constraint failed when trying to share video via intent

此生再无相见时 提交于 2019-12-08 07:28:28
问题 Hey I'm trying to develop an app which would allow users to share video files. Whenever I try to share the same video file for the second time I get constraint failed error 11-21 20:46:47.103 1076-4528/? E/SQLiteDatabase﹕ Error inserting bucket_id=-1634214109 date_modified=1448138795 datetaken=1448138795000 bucket_display_name=.estrongs parent=894 format=12299 storage_id=131073 media_type=3 mime_type=video/mp4 _size=1235266 title=video1 _data=/storage/sdcard1/.estrongs/video1.mp4 date_added

Manual add song to Mediastore as a music track

北战南征 提交于 2019-12-06 20:32:00
问题 I want to create a Music player which can download a song online and add it to MediaStore. I'm using Download Manager and allow MediaScanner scan this file when download completed. DownloadManager.Request request .... request.allowScanningByMediaScanner(); ... downloadManager.enqueue(request); It's work fine in android 5.0 and above. But the song was downloaded using codec (opus) which not supported in android below lollipop version, so MediaScanner doesn't add this file to MediaStore. That's

Android mediaScannerConnection.scanFile failing to refresh images in gallery

好久不见. 提交于 2019-12-06 04:19:51
Should I be using something other than the MediaScannerConnection.scanFile method to refresh the gallery? After saving a new jpg I run media scanner to refresh the gallery app like so MediaScannerConnection.scanFile(this, new String[] { fullname }, null, new MediaScannerConnection.OnScanCompletedListener() { public void onScanCompleted(String path, Uri uri) { Log.d("ExternalStorage", "@@@@ Scanned " + path + ":"); Log.d("ExternalStorage", "@@@@ -> uri=" + uri); } }); The output of the log shows the following correct output @@@@ Scanned /data/data/com.mypackage/files/skit_106_01.jpg: @@@@ ->

Manual add song to Mediastore as a music track

会有一股神秘感。 提交于 2019-12-05 01:28:38
I want to create a Music player which can download a song online and add it to MediaStore. I'm using Download Manager and allow MediaScanner scan this file when download completed. DownloadManager.Request request .... request.allowScanningByMediaScanner(); ... downloadManager.enqueue(request); It's work fine in android 5.0 and above. But the song was downloaded using codec ( opus ) which not supported in android below lollipop version, so MediaScanner doesn't add this file to MediaStore. That's my problem, my app can play opus codec but the song didn't exist in MediaStore after it has

Refreshing the thumbnail using MediaScanner

坚强是说给别人听的谎言 提交于 2019-12-04 20:35:58
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 (FileNotFoundException e) { } //refreshing single file using media scanner, no need to paste This is a

How to listen new photos in android?

左心房为你撑大大i 提交于 2019-12-03 15:08:34
I need to listen to new images that comes from any source like downloading images, capture new images, other apps download images..etc Is there any listener that will trigger event whenever new photos is added to gallery? I have been searching for two days. I could not get anything solid. I read about FileObserver , will that help? new photos arrives to gallery means it has been added to the MediaStore . First of all, FileOberver is a memory-killer approach. Consider a high volume of files. Rather ContentObserver seems a far better approach. getContentResolver().registerContentObserver(android

How to correctly notify MediaScanner about a folder, even on Nexus/Kitkat devices?

和自甴很熟 提交于 2019-12-03 12:33:29
Background I'm making an app that downloads some images from the Internet into a specific folder that is defined as: final String pathToPutFiles = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + DOWNLOAD_FOLDER_NAME; I wish to make the gallery and any app that shows media, to be notified of those images and be able to show them. Sadly I'm having problems on Nexus 4, which has Kitkat version (4.4.2 to be exact). Sometimes it works and sometimes it doesn't. The problem There are plenty of posts about this issue, and I've tried many of them and

How to get notified of each new image being visible to the gallery app?

不问归期 提交于 2019-12-03 11:55:47
问题 Background When the user downloads a new image or captures one using the camera, the gallery app will get updated to show the new images. I need to be notified of each new image as soon as it was created, no matter how it was created (camera, browser,...) , just as the gallery app shows. The problem As it turns out there is a mediaScanner Android component that is responsible for scanning all types of media files, and when it finishes, it's supposed to send an intent "MEDIA_SCANNER_FINISHED"

How to get notified of each new image being visible to the gallery app?

半城伤御伤魂 提交于 2019-12-03 02:18:43
Background When the user downloads a new image or captures one using the camera, the gallery app will get updated to show the new images. I need to be notified of each new image as soon as it was created, no matter how it was created (camera, browser,...) , just as the gallery app shows. The problem As it turns out there is a mediaScanner Android component that is responsible for scanning all types of media files, and when it finishes, it's supposed to send an intent " MEDIA_SCANNER_FINISHED " (as shown on this example ) . So I've added the next code , hoping it will show a toast each time the