mediastore

MediaStore.Images.Media.insertImage return null sometimes

孤街醉人 提交于 2019-11-28 09:42:12
问题 I encountered strange problem, when calling MediaStore.Images.Media.insertImage, it returns null uri sometimes, but I found it can work well one or two times, I can't find it's rule. Please give help, thanks a lot! the logcat is: 06-18 11:09:24.559: E/MediaStore(13050): Thumbnail is not generated in query() with blockingUri. Return null! 06-18 11:09:24.567: E/MediaStore(13050): Failed to insert image 06-18 11:09:24.567: E/MediaStore(13050): java.lang.NullPointerException 06-18 11:09:24.567: E

Android cursor error - “make sure cursor is initialized correctly before accessing data from it…”

最后都变了- 提交于 2019-11-28 09:14:25
I've got an activity where a viewflipper shows a list containing the artists from mediastore, which onitem click display a list of albums by the chosen artist, which in turn displays the songs on that album. Once a song is clicked, it should populate a textview with the string 'title'. Until this point, all of the cursors are working fine, but the very last one seems to get put out of position somehow. Could anyone tell me why logcat is telling me: 05-07 23:58:54.195: E/AndroidRuntime(1961): java.lang.IllegalStateException: Couldn't read row 3, col -1 from CursorWindow. Make sure the Cursor is

Android MediaStore insertVideo

对着背影说爱祢 提交于 2019-11-28 08:46:10
So our app has the option to take either a picture or a video. If the user takes a picture, we can use the MediaStore.Images.Media.insertImage function to add the new image (via a filepath) to the phone's gallery and generate a content:// style URI. Is there a similar process for a captured video, given that we only have it's filepath? Here is an easy 'single file based solution': Whenever you add a file, let MediaStore Content Provider knows about it using sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(imageAdded))); Main advantage: work with any mime type

Get MediaStore path of a Specific Folder

牧云@^-^@ 提交于 2019-11-28 08:40:04
问题 I'm creating an update for my application, in it I have a folder with saved images that I would like to display in a GridView. I am already using the Ion library. The creator of the library (Koush Dutta) already has a sample doing what I want and displays all of the images from the SD Card in a GridView.. What I want to do is display only the images from a specific folder on my SD Card (called comics) in the GridView. I am using the code directly from the sample above, only modifying some

Android: How to detect a change in MediaStore when connected over MTP

99封情书 提交于 2019-11-28 06:39:03
I have big problems with MediaStore. I need to handle events when MediaStore is changed over MTP. I already have a receiver for android.intent.action.MEDIA_SCANNER_FINISHED action, but it is useful only for Universal Mass Storage(UMS). The scanner is not launched over MTP, because the MTP changes the MediaStore database directly. Please would you be so kind and help me how to detect this events. Thank you very much for any help! I finally found a solution. I tried to use FileObserver but when you use it for all directories...it is quite memory consuming. So now I am using ContentObserver and

Android Can I use JOIN at mediastore query

这一生的挚爱 提交于 2019-11-28 05:43:16
问题 is there any method to use join in a query at mediastore data? Or also is there any method to access the mediastore data through a database and not with the content provider? Thank you. 回答1: But I think that you can use joins with content providers. If you make two queries, you can join them by using CursorJoiner. I am using it and it works good. Snippet from Android docs: CursorJoiner joiner = new CursorJoiner(cursorA, keyColumnsofA, cursorB, keyColumnsofB); for (CursorJointer.Result

Get Album Art With Album Name Android

跟風遠走 提交于 2019-11-28 05:08:59
I want to display album art with album name in listview. But i am not getting the way to display album art. I have tried from cover art on android . Here is my Code : Cursor cursor = managedQuery(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, null, null, null, null); if (cursor == null) { //Query Failed , Handle error. } else if (!cursor.moveToFirst()) { //No media on the device. } else { int titleColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Albums.ALBUM_ART); int id = cursor.getColumnIndex(android.provider.MediaStore.Audio.Albums.ALBUM_ID); //here value i m getting -1 . for

How to get and set (change) ID3 tag (metadata) of audio files?

拥有回忆 提交于 2019-11-28 03:43:12
I am working to change ID3 tags, the metadata in audio files, such as: Artist Title Album etc. And the core point,. that edited ID3 tags should be shown only into my app. MKJParekh I think this is what you are looking for MyID3 library to set and get tags for media file. Download this jar file MyID3_for_android and add it to your project's build path. here is the sample code. here pathdata is the file path of the audio file. File src = new File(pathdata); MusicMetadataSet src_set = null; try { src_set = new MyID3().read(src); } catch (IOException e1) { // TODO Auto-generated catch block e1

Android - MediaStore.Video.query() is returning null

岁酱吖の 提交于 2019-11-28 00:50:05
问题 I'm trying to retrieve the metadata from a video file (title, language, artist) using the method MediaStore.Video.query(). However, the method is always returning null. The code is bellow: String[] columns = { MediaStore.Video.VideoColumns._ID, MediaStore.Video.VideoColumns.TITLE, MediaStore.Video.VideoColumns.ARTIST }; Cursor cursor = MediaStore.Video.query(getApplicationContext().getContentResolver(), videoUri,columns); if (cursor != null) { cursor.moveToNext(); } String title = cursor

Setting Ringtone notification from SD card file

泄露秘密 提交于 2019-11-28 00:33:32
My goal is to set the users notification sound from a file that is stored onto the SD card from with in the application. I am using this code: if(path != null){ File k = new File(path, "moment.mp3"); ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, "My Song title"); values.put(MediaStore.MediaColumns.SIZE, 215454); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3"); values.put(MediaStore.Audio.Media.ARTIST, "Some Artist"); values.put(MediaStore.Audio.Media.DURATION, 230); values.put