mediastore

Listing thumbnails per bucket

此生再无相见时 提交于 2019-12-02 06:36:33
I have 2 classes. First is meant for searching for all folders, I mean Bucket list name. Seconds class makes thumbnails. But I need to have thumbnails per bucket. So when I push on my folder it should shows me all photos in it (thumbnails). Can somebody help me with it? First class: public class ThumbnailAdapter extends BaseAdapter { // Context required for performing queries private final Context mContext; // Cursor for thumbnails private final Cursor cursor; private final int imgId; private final int imgData; private final int count; public ThumbnailAdapter(Context c) { this.mContext = c; //

Joining cursors and sorting

元气小坏坏 提交于 2019-12-02 06:28:40
I'm writing a "gallery-type" app for Android. In the "master activity", I have a GridView which I want to load/fill with thumbnails from photos on the device. So I've written a ContentProvider, where the query method returns a cursor from MediaStore.Media.Thumbnails. However, I also want to display some meta data from MediaStore.Media.Images. In order to do this, I ended up using a CursorJoiner to join c_thumbs and c_images on ID. Only problem with this, is that CursorJoiner requires the input cursors to already be sorted (ordered) on the join key (ID), in ascending order. What I want is

Wrong DURATION in MediaStore.Video.Media.DURATION

扶醉桌前 提交于 2019-12-02 03:59:11
I'm trying to record video in my application and I've noticed that displaying their duration , I see wrong minutes \ seconds. This happens only with the video recorded trough the following code. With the video recorded through other apps, the duration is displayed right: public void recordStream() { //Release Camera before MediaRecorder start releaseCamera(); if(!prepareMediaRecorder()){ Toast.makeText(MainActivity.this, "Fail in prepareMediaRecorder()!\n - Ended -", Toast.LENGTH_LONG).show(); } mediaRecorder.start(); } } private boolean prepareMediaRecorder(){ myCamera = getCameraInstance();

MediaStore.Audio.Albums.ALBUM_ID invalid column

久未见 提交于 2019-12-02 03:25:57
问题 I can't get the albumID from MediaStore, i get -1 from getColumnIndex . Here is my code: Cursor cursor = mContext.getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, null, null, null, null); if (cursor.moveToFirst() == false) { //no rows empty cursor } int albumColumnIndex = cursor.getColumnIndex(Audio.Albums.ALBUM); int albumidColumnIndex = cursor.getColumnIndex(Audio.Albums.ALBUM_ID); String album = cursor.getString(albumColumnIndex); int id = cursor.getInt

MediaStore.Audio.Albums.ALBUM_ID invalid column

时光怂恿深爱的人放手 提交于 2019-12-02 01:42:14
I can't get the albumID from MediaStore, i get -1 from getColumnIndex . Here is my code: Cursor cursor = mContext.getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, null, null, null, null); if (cursor.moveToFirst() == false) { //no rows empty cursor } int albumColumnIndex = cursor.getColumnIndex(Audio.Albums.ALBUM); int albumidColumnIndex = cursor.getColumnIndex(Audio.Albums.ALBUM_ID); String album = cursor.getString(albumColumnIndex); int id = cursor.getInt(albumidColumnIndex); while(cursor.moveToNext()) { album = cursor.getString(albumColumnIndex); id = cursor.getInt

How does CursorAdapter work on android in GridView

扶醉桌前 提交于 2019-12-01 20:45:55
问题 I have a problem with using cursor adapter on gridview which I used the cursor to load photos from the media store. I realized my newView and bindView got called completely. I mean assuming i have 500 photos, the newView also get called the same number of times. Did I do anything wrong ? I thought it will only call when the cell was visible on the screen.. public int taskA = 0; public GalleryCursorAdapter(Context context, Cursor c) { super(context, c); // TODO Auto-generated constructor stub

How to clear Mediastore before setting ringtone

十年热恋 提交于 2019-12-01 07:30:21
问题 When I set a ringtone from my app works once, but when running the code again, it tries to create a duplicate entry in the media store, which creates problems. Without creating seperate unique file names for every sound file, I want to fix this problem. I found this solution posted in an answer here: setting audio file as Ringtone and am trying to use that to fix mine. When I try it in my code below, I get two errors. One is an SQLiteException and the other is a RuntimeException which is

Querying Playlist from MediaStore

匆匆过客 提交于 2019-12-01 01:45:12
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] = new ContentValues(); values[i].put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, i + count + 1); values

Getting efficiently the Genres of the Audio files in the MediaStore

▼魔方 西西 提交于 2019-12-01 00:25:28
I am trying to synchronize my own database for tracks and albums (that contains additional data). I have so far successfully pulled albums and tracks from the MediaStore. What I cannot manage to do properly is to pull the Genres for the tracks. Could someone post some code? I'd like to avoid querying the database for each track, so if possible some code to load the association (Genre.id <-> Audio.id) would be great. What I am struggling on is using the content provider to get the Genres.Members info. I'd take a look at how the excellent creators of ringdroid do this. http://ringdroid

MediaStore.Images.Media.insertImage throwing permission denial on some devices

泄露秘密 提交于 2019-11-30 20:53:05
I have problem with line of code: String path = MediaStore.Images.Media.insertImage(activity.getContentResolver(), bitmap, "feedback", null); Activity is not null, bitmap is not null. I get error: 0-22 11:23:59.644 29514-29527/? E/DatabaseUtils: Writing exception to parcel 10-22 11:23:59.644 29514-29527/? E/DatabaseUtils: java.lang.SecurityException: Permission Denial: writing com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=1380, uid=10136 requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission() 10-22 11:23:59.644 29514-29527/? E