当前位置: 首页>>代码示例>>Java>>正文


Java MediaColumns类代码示例

本文整理汇总了Java中android.provider.MediaStore.MediaColumns的典型用法代码示例。如果您正苦于以下问题:Java MediaColumns类的具体用法?Java MediaColumns怎么用?Java MediaColumns使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MediaColumns类属于android.provider.MediaStore包,在下文中一共展示了MediaColumns类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDataColumn

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
private String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {  
    Cursor cursor = null;  
    String[] column = {MediaColumns.DATA};  
  
    try {  
        cursor = context.getContentResolver().query(uri, column, selection, selectionArgs, null);  
        if (cursor != null && cursor.moveToFirst()) {  
            final int index = cursor.getColumnIndexOrThrow(column[0]);  
            return cursor.getString(index);  
        }  
    } catch (Exception e) {
		Log.e("getRealPath error ", "exception: " + e);
    } finally {  
        if (cursor != null)  
            cursor.close();  
    }  
    return null;  
}
 
开发者ID:lbbniu,项目名称:CCDownload,代码行数:19,代码来源:UploadFragment.java

示例2: move

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
public boolean move(File srcFile, File targetFile) {
    boolean res = srcFile.renameTo(targetFile);
    if (res) {
        // Add the new file to the medialib
        scanFile(targetFile);

        // Remove the source file from the medialib
        //            scanFile(srcFile);
        ContentResolver cr = context.getContentResolver();
        Uri uri = MediaStore.Files.getContentUri("external");
        String where = MediaColumns.DATA + "=?";
        String[] selectionArgs = { srcFile.getPath() };
        cr.delete(uri, where, selectionArgs);
    }
    return res;
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:17,代码来源:FileManagerCore.java

示例3: getUriImagePathQuery

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
/**
 * 获取媒体数据库路径 . <br>
 * @author liulongzhenhai 2012-8-1 下午5:09:27 <br>
 * @param ct 上下文
 * @param contentUri URI地址
 * @return 返回相应的绝对路径
 */
public static String getUriImagePathQuery(final Context ct, final Uri contentUri) {
	// can post image
	if (contentUri == null) {
		return "";
	}

	final String[] proj = { MediaColumns.DATA };
	String path = "";
	final Cursor cursor = ct.getContentResolver().query(contentUri, proj, null, null, null);
	if (cursor != null) {
		if (cursor.moveToFirst()) {
			path = cursor.getString(cursor.getColumnIndexOrThrow(MediaColumns.DATA));
		}
		cursor.close();
	}
	return path;
}
 
开发者ID:VK2012,项目名称:AppCommonFrame,代码行数:25,代码来源:BitmapUtil.java

示例4: getSongListForGenre

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param id      The ID of the genre.
 * @return The song list for an genre.
 */
public static final long[] getSongListForGenre(final Context context, final long id) {
    final String[] projection = new String[]{
            BaseColumns._ID
    };
    String selection = (AudioColumns.IS_MUSIC + "=1") +
            " AND " + MediaColumns.TITLE + "!=''";
    final Uri uri = MediaStore.Audio.Genres.Members.getContentUri("external", Long.valueOf(id));
    Cursor cursor = context.getContentResolver().query(uri, projection, selection,
            null, null);
    if (cursor != null) {
        final long[] mList = getSongListForCursor(cursor);
        cursor.close();
        cursor = null;
        return mList;
    }
    return sEmptyList;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:23,代码来源:MusicUtils.java

示例5: getImagePath

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
/**
 * 获取图片路径 2014年8月12日
 *
 * @param uri
 * @return E-mail:[email protected]
 */
public static String getImagePath(Uri uri, Activity context) {

    String[] projection = {MediaColumns.DATA};
    Cursor cursor = context.getContentResolver().query(uri, projection,
            null, null, null);
    if (cursor != null) {
        cursor.moveToFirst();
        int columIndex = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
        String ImagePath = cursor.getString(columIndex);
        cursor.close();
        return ImagePath;
    }

    return uri.toString().replace("file://", "");
}
 
开发者ID:giantss,项目名称:com.giants.multiimagespicker,代码行数:22,代码来源:ImageUtils.java

示例6: getMp3List

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
public static List<Playlist> getMp3List(Context context) {
    List<Playlist> list = new ArrayList<Playlist>();

    Cursor cursor = new ResolverSer().getResolverSer().getResover(context).query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, media_info, "",
            null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
    if (cursor != null && cursor.getCount() == 0) {
        final AlertDialog xfdialog = new AlertDialog.Builder(context).setTitle("Tips:").setMessage(context.getResources().getString(R.string.music_no_one)).setPositiveButton(context.getResources().getString(R.string.is_positive), null).create();
        xfdialog.show();
        cursor.close();
        return null;
    }
    while (cursor.moveToNext()) {
        int id = cursor.getInt(cursor.getColumnIndex(BaseColumns._ID));
        int album_id = cursor.getInt(cursor.getColumnIndex(AudioColumns.ALBUM_ID));
        String title = cursor.getString(cursor.getColumnIndex(MediaColumns.TITLE));
        String artist = cursor.getString(cursor.getColumnIndex(AudioColumns.ARTIST));
        int duration = cursor.getInt(cursor.getColumnIndex(AudioColumns.DURATION));
        if (duration > 30000) {
            Playlist playlist = new Playlist(id, title, duration, artist, album_id);
            list.add(playlist);
        }
    }
    cursor.close();
    return list;
}
 
开发者ID:Alex-Jerry,项目名称:LLApp,代码行数:26,代码来源:MusicUtil.java

示例7: getSongListForGenre

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
/**
 * @param context
 * @param id
 * @return
 */
public static long[] getSongListForGenre(Context context, long id) {
    String[] projection = new String[] {
        BaseColumns._ID
    };
    StringBuilder selection = new StringBuilder();
    selection.append(AudioColumns.IS_MUSIC + "=1");
    selection.append(" AND " + MediaColumns.TITLE + "!=''");
    Uri uri = Genres.Members.getContentUri(EXTERNAL, id);
    Cursor cursor = context.getContentResolver().query(uri, projection, selection.toString(),
            null, null);
    if (cursor != null) {
        long[] list = getSongListForCursor(cursor);
        cursor.close();
        return list;
    }
    return sEmptyList;
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:23,代码来源:MusicUtils.java

示例8: doSearch

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
/**
 * Create a Search Chooser
 */
public static void doSearch(Context mContext, Cursor mCursor, String Type) {
    CharSequence title = null;
    Intent i = new Intent();
    i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    String query = "";

	if ( Type == TYPE_ALBUM ){
		query = mCursor.getString(mCursor.getColumnIndexOrThrow(AlbumColumns.ALBUM));
	}
	else if( Type == TYPE_ARTIST ){
		query = mCursor.getString(mCursor.getColumnIndexOrThrow(ArtistColumns.ARTIST));
	}
	else if( Type == TYPE_GENRE ||  Type == TYPE_PLAYLIST ||  Type == TYPE_SONG ){
		query = mCursor.getString(mCursor.getColumnIndexOrThrow(MediaColumns.TITLE));
	}
    title = "";
    i.putExtra("", query);
    title = title + " " + query;
    title = "Search " + title;
    i.putExtra(SearchManager.QUERY, query);
    mContext.startActivity(Intent.createChooser(i, title));
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:27,代码来源:MusicUtils.java

示例9: onCreateContextMenu

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if( mFragmentGroupId != 0 ){
 	menu.add(mFragmentGroupId, PLAY_SELECTION, 0, getResources().getString(R.string.play_all));
     menu.add(mFragmentGroupId, ADD_TO_PLAYLIST, 0, getResources().getString(R.string.add_to_playlist));
     menu.add(mFragmentGroupId, USE_AS_RINGTONE, 0, getResources().getString(R.string.use_as_ringtone));
     menu.add(mFragmentGroupId, REMOVE, 0, R.string.remove);
     menu.add(mFragmentGroupId, SEARCH, 0, getResources().getString(R.string.search));
     AdapterContextMenuInfo mi = (AdapterContextMenuInfo)menuInfo;
     mSelectedPosition = mi.position;
     mCursor.moveToPosition(mSelectedPosition);
     try {
         mSelectedId = mCursor.getLong(mCursor.getColumnIndexOrThrow(mMediaIdColumn));
     } catch (IllegalArgumentException ex) {
         mSelectedId = mi.id;
     }
     String title = mCursor.getString(mCursor.getColumnIndexOrThrow(MediaColumns.TITLE));
     menu.setHeaderTitle(title);
    }
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:21,代码来源:DragSortListViewFragment.java

示例10: onCreateLoader

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
	String[] projection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST,
    };
    StringBuilder selection = new StringBuilder();
    Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
    String sortOrder = Audio.Media.DEFAULT_SORT_ORDER;
    uri = Audio.Media.EXTERNAL_CONTENT_URI;
    long[] mNowPlaying = MusicUtils.getQueue();
    if (mNowPlaying.length == 0)
        return null;
    selection = new StringBuilder();
    selection.append(BaseColumns._ID + " IN (");
    if (mNowPlaying == null || mNowPlaying.length <= 0)
        return null;
    for (long queue_id : mNowPlaying) {
        selection.append(queue_id + ",");
    }
    selection.deleteCharAt(selection.length() - 1);
    selection.append(")");
	
    return new AddIdCursorLoader(getActivity(), uri, projection, selection.toString(), null,
            sortOrder);
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:26,代码来源:QuickQueueFragment.java

示例11: reloadQueueCursor

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
/**
 * Reload the queue after we remove a track
 */
private void reloadQueueCursor() {
    String[] projection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST,
    };
    StringBuilder selection = new StringBuilder();
    Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
    String sortOrder = Audio.Media.DEFAULT_SORT_ORDER;
    uri = Audio.Media.EXTERNAL_CONTENT_URI;
    long[] mNowPlaying = MusicUtils.getQueue();
    if (mNowPlaying.length == 0)
        return;
    selection = new StringBuilder();
    selection.append(BaseColumns._ID + " IN (");
    if (mNowPlaying == null || mNowPlaying.length <= 0)
        return;
    for (long queue_id : mNowPlaying) {
        selection.append(queue_id + ",");
    }
    selection.deleteCharAt(selection.length() - 1);
    selection.append(")");

    mCursor = MusicUtils.query(getActivity(), uri, projection, selection.toString(), null,
            sortOrder);
    mQuickQueueAdapter.changeCursor(mCursor);
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:29,代码来源:QuickQueueFragment.java

示例12: setupFragmentData

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
@Override
public void setupFragmentData() {
       mAdapter = new AlbumListAdapter(getActivity(), R.layout.music_listview_items, null,
               								new String[] {}, new int[] {}, 0);
   	mProjection = new String[] {
               BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
       };
       StringBuilder where = new StringBuilder();
       where.append(AudioColumns.IS_MUSIC + "=1")
       					.append(" AND " + MediaColumns.TITLE + " != ''");
       long albumId = getArguments().getLong(BaseColumns._ID);
       where.append(" AND " + AudioColumns.ALBUM_ID + "=" + albumId);
       mWhere = where.toString();        
       mSortOrder = Audio.Media.TRACK + ", " + Audio.Media.DEFAULT_SORT_ORDER;
       mUri = Audio.Media.EXTERNAL_CONTENT_URI;
       mFragmentGroupId = 89;
       mType = TYPE_ALBUM;
       mTitleColumn = MediaColumns.TITLE; 
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:20,代码来源:AlbumListFragment.java

示例13: setupFragmentData

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
public void setupFragmentData(){
    mAdapter = new RecentlyAddedAdapter(getActivity(), R.layout.music_listview_items,
            null, new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
    };
    StringBuilder where = new StringBuilder();
    int X = MusicUtils.getIntPref(getActivity(), NUMWEEKS, 5) * 3600 * 24 * 7;
    where.append(MediaColumns.TITLE + " != ''");
    where.append(" AND " + AudioColumns.IS_MUSIC + "=1");
    where.append(" AND " + MediaColumns.DATE_ADDED + ">"
            + (System.currentTimeMillis() / 1000 - X));
    mWhere = where.toString();
    mSortOrder = MediaColumns.DATE_ADDED + " DESC";
    mUri = Audio.Media.EXTERNAL_CONTENT_URI;
    mTitleColumn = MediaColumns.TITLE;       
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:18,代码来源:RecentlyAddedFragment.java

示例14: onLoadFinished

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
@Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
      if (data == null) {
          return;
      }
      long[] mNowPlaying = MusicUtils.getQueue();
  	String[] audioCols = new String[] { BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ARTIST, AudioColumns.ALBUM};
      MatrixCursor playlistCursor = new MatrixCursor(audioCols);
  	for(int i = 0; i < mNowPlaying.length; i++){
  		data.moveToPosition(-1);
  		while (data.moveToNext()) {
              long audioid = data.getLong(data.getColumnIndexOrThrow(BaseColumns._ID));
          	if( audioid == mNowPlaying[i]) {
                  String trackName = data.getString(data.getColumnIndexOrThrow(MediaColumns.TITLE));
                  String artistName = data.getString(data.getColumnIndexOrThrow(AudioColumns.ARTIST));
                  String albumName = data.getString(data.getColumnIndexOrThrow(AudioColumns.ALBUM));
          		playlistCursor.addRow(new Object[] {audioid, trackName, artistName, albumName });
          	}
          }
  	}
      data.close();
mCursor = playlistCursor;
      super.onLoadFinished(loader, playlistCursor);
  }
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:25,代码来源:NowPlayingFragment.java

示例15: setupFragmentData

import android.provider.MediaStore.MediaColumns; //导入依赖的package包/类
public void setupFragmentData(){
    mAdapter = new GenreListAdapter(getActivity(), R.layout.music_listview_items, null,
            								new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM,
            AudioColumns.ARTIST
    };
    StringBuilder where = new StringBuilder();
    where.append(AudioColumns.IS_MUSIC + "=1").append(
            				" AND " + MediaColumns.TITLE + " != ''");
    mWhere = where.toString();        
    mSortOrder = Genres.Members.DEFAULT_SORT_ORDER;
    mUri = Genres.Members.getContentUri(EXTERNAL, getArguments().getLong(BaseColumns._ID));
    mFragmentGroupId = 3;
    mType = TYPE_GENRE;
    mTitleColumn = MediaColumns.TITLE; 
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:18,代码来源:GenreListFragment.java


注:本文中的android.provider.MediaStore.MediaColumns类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。