mediastore

Unknown URI Error in insertImage

十年热恋 提交于 2019-12-05 06:37:04
Trying saving bitmap into gallery Bitmap bitmap = Bitmap.createBitmap(surfaceView.getWidth(), surfaceView.getHeight(), Bitmap.Config.ARGB_8888); surfaceView.draw(new Canvas(bitmap)); MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "foo" , "bar"); I ran the application on the emulator and got an UnsupportedOperationException. 07-25 22:27:48.719: E/MediaStore(1918): Failed to insert image 07-25 22:27:48.719: E/MediaStore(1918): java.lang.UnsupportedOperationException: Unknown URI: content://media/external/images/media 07-25 22:27:48.719: E/MediaStore(1918): at android.database

What is the best way for pick a video in Android

核能气质少年 提交于 2019-12-05 05:42:54
I got a perfect Intent.ACTION_PICK with my picture. startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), SELECT_IMAGE); But it doesn't work with video. When i click on a video of my list, it play the vidoe instead of send me back. startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Video.Media.INTERNAL_CONTENT_URI), SELECT_VIDEO); An idea ? typo.pl You want to use Intent.ACTION_GET_CONTENT and specify video/* for the type to pass to Intent.setType . See Stackoverflow - Android access videos and

Getting audio file path or URI from mediastore

自作多情 提交于 2019-12-05 02:57:28
问题 I am making an application which lists all the songs on the device onto the screen and clicking on them opens a sharing intent where the songs / audio file can be shared across various devices through different method like Bluetooth, WhatsApp etc. But I am not able to get the file path or location of the audio file from the mediastore. This is how I am getting my songs- public void getSongList() { //retrieve song info ContentResolver musicResolver = getActivity().getContentResolver(); Uri

Getting album art from the audio file Uri

人盡茶涼 提交于 2019-12-05 02:12:02
问题 I am trying to get the album art from the audio file Uri, here is my code: // uri is the audio file uri public static Bitmap getSongCoverArt(Context context, Uri uri){ Bitmap songCoverArt = null; String[] projections = {MediaStore.Audio.Media.ALBUM_ID}; Cursor cursor = null; try { cursor = context.getContentResolver().query(uri, projections, null, null, null); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM_ID); cursor.moveToFirst(); Uri songCover = Uri.parse(

Is there any way to look for an image using the path? MediaStore.Images.Thumbnails (Android)

北战南征 提交于 2019-12-04 16:49:15
I'm using MediaStore.Images.Thumbnails in order to show the images the user have. But i'm not able to get an image through its path. Is there any way to look for an image using the path? String [] proj={MediaStore.Images.Thumbnails._ID, MediaStore.Images.Thumbnails.IMAGE_ID, MediaStore.Images.Media.DATA}; String selection = MediaStore.Images.Media.DATA + " like '%path%'"; //this doesn't work cursor = managedQuery( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, proj, // Which columns to return selection, // WHERE clause; null, null); // Order-by clause Best regards! Jett Hsieh EDITED Hi, /

Playing audio from MediaStore on a Media Player Android

泄露秘密 提交于 2019-12-04 12:03:33
Is there a way to play audio obtained from MediaStore through the use of the MediaPLayer, Or am I going in the completely wrong direction? I've looked and MediaStore.Audio so far but nothing is really helping me. I just need to know if I'm on the right track First, I assume you have basic knowledge of querying a ContentProvider and working with Cursors. If you dont, I suggest you research it here Once you have a basic knowledge of how to use a ContentProvider, query the URI MediaStore.Audio.Media.EXTERNAL_CONTENT_URI for the column Audio.Media.DATA , along with any other fields you need. Let's

Android video file path from media store is coming as null

冷暖自知 提交于 2019-12-04 05:38:36
问题 I am trying to get the path of the video file for a video thumbnail. I'm not sure why it is still coming as null after I modified based on some solutions here. The version of android is 6.0.1. The user clicks the floating action button and summons a gallery of videos. FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.addNote); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(); intent.setType("video/*")

MediaStore.Images.Thumbnails.getThumbnail returns wrong thumbnail instead of NULL

社会主义新天地 提交于 2019-12-04 02:08:50
Consider the scenario as in this picture: Three photos, one of them is a large GIF file (3MP). I'm querying MediaStore in order to retrieve the correspondent thumbnails. If I initialize the Cursor via CursorLoader with this sortOrder: MediaStore.Images.Media.DATE_ADDED + " DESC"" What happens: MediaStore returns the previous successfully retrieved thumbnail: Expected behaviour: when MediaStore cannot retrieve the thumbnail of a given image for some reason it has to return NULL, as per its Javadoc: "... Returns A Bitmap instance. It could be null if the original image associated with origId

Android: Is EXTERNAL_CONTENT_URI enough for a photo gallery?

一世执手 提交于 2019-12-03 23:54:00
I'm playing around with Android's MediaStore classes and was attempting to create a very simple photo gallery app when I noticed that were two image content URIs: EXTERNAL_CONTENT_URI and INTERNAL_CONTENT_URI . At first I thought it was referring to the location of storage (external SD or internal memory) but after a bit of testing this was clearly not the case. I read more about it here , and it seemed to indicate that the internal content uri is actually content that are internal to each of the apps on the device. However I am not entirely sure and wanted opinions from more experienced

Querying Playlist from MediaStore

与世无争的帅哥 提交于 2019-12-03 23:03:00
问题 I'm trying to query playlists in the device from MediaStore. I have followed a question asked before but I didn't get the answer. This is how I query for playlists public void addToPlaylist(long playlistId, Context context, ArrayList<Play> playlistTracks, String playlistName) { int count = getPlaylistSize(playlistId, context); Log.d("playlist size=", "" + count); ContentValues[] values = new ContentValues[playlistTracks.size()]; for (int i = 0; i < playlistTracks.size(); i++) { values[i] =