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


Java AlbumColumns类代码示例

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


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

示例1: getIdForAlbum

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
/**
 * Returns the ID for an album.
 *
 * @param context    The {@link Context} to use.
 * @param albumName  The name of the album.
 * @param artistName The name of the artist
 * @return The ID for an album.
 */
public static final long getIdForAlbum(final Context context, final String albumName,
                                       final String artistName) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, new String[]{
                    BaseColumns._ID
            }, AlbumColumns.ALBUM + "=? AND " + AlbumColumns.ARTIST + "=?", new String[]{
                    albumName, artistName
            }, AlbumColumns.ALBUM);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:28,代码来源:MusicUtils.java

示例2: getSongCountForAlbumInt

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param id      The id of the album.
 * @return The song count for an album.
 */
public static final int getSongCountForAlbumInt(final Context context, final long id) {
    int songCount = 0;
    if (id == -1) {
        return songCount;
    }

    Uri uri = ContentUris.withAppendedId(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, id);
    Cursor cursor = context.getContentResolver().query(uri,
            new String[]{AlbumColumns.NUMBER_OF_SONGS}, null, null, null);
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            if (!cursor.isNull(0)) {
                songCount = cursor.getInt(0);
            }
        }
        cursor.close();
        cursor = null;
    }

    return songCount;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:28,代码来源:MusicUtils.java

示例3: getReleaseDateForAlbum

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param id      The id of the album.
 * @return The release date for an album.
 */
public static final String getReleaseDateForAlbum(final Context context, final long id) {
    if (id == -1) {
        return null;
    }
    Uri uri = ContentUris.withAppendedId(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, id);
    Cursor cursor = context.getContentResolver().query(uri, new String[]{
            AlbumColumns.FIRST_YEAR
    }, null, null, null);
    String releaseDate = null;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            releaseDate = cursor.getString(0);
        }
        cursor.close();
        cursor = null;
    }
    return releaseDate;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:25,代码来源:MusicUtils.java

示例4: doSearch

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的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:cpoopc,项目名称:com.cp.monsterMod,代码行数:27,代码来源:MusicUtils.java

示例5: getIdForAlbum

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
/**
 * Returns the ID for an album.
 *
 * @param context The {@link Context} to use.
 * @param albumName The name of the album.
 * @param artistName The name of the artist
 * @return The ID for an album.
 */
public static long getIdForAlbum(final Context context, final String albumName, final String artistName) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, new String[] {
                BaseColumns._ID
            }, AlbumColumns.ALBUM + "=? AND " + AlbumColumns.ARTIST + "=?", new String[] {
                albumName, artistName
            }, AlbumColumns.ALBUM);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:27,代码来源:MusicUtils.java

示例6: getIdForAlbum

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
/**
 * Returns the ID for an album.
 * 
 * @param context The {@link Context} to use.
 * @param name The name of the album.
 * @return The ID for an album.
 */
public static final long getIdForAlbum(final Context context, final String name) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, new String[] {
                BaseColumns._ID
            }, AlbumColumns.ALBUM + "=?", new String[] {
                name
            }, AlbumColumns.ALBUM);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:26,代码来源:MusicUtils.java

示例7: getAlbumArtist

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
/**
 * Returns the artist name for a album.
 * 
 * @param context The {@link Context} to use.
 * @param name The name of the album.
 * @return The artist for an album.
 */
public static final String getAlbumArtist(final Context context, final String name) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, new String[] {
                AlbumColumns.ARTIST
            }, AlbumColumns.ALBUM + "=?", new String[] {
                name
            }, AlbumColumns.ALBUM);
    String artistName = null;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            artistName = cursor.getString(0);
        }
        cursor.close();
        cursor = null;
    }
    return artistName;
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:26,代码来源:MusicUtils.java

示例8: getSongCountForAlbum

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param name The name of the album.
 * @return The song count for an album.
 */
public static final String getSongCountForAlbum(final Context context, final String name) {
    if (name == null) {
        return null;
    }
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, new String[] {
                AlbumColumns.NUMBER_OF_SONGS
            }, AlbumColumns.ALBUM + "=?", new String[] {
                name
            }, AlbumColumns.ALBUM);
    String songCount = null;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            songCount = cursor.getString(0);
        }
        cursor.close();
        cursor = null;
    }
    return songCount;
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:27,代码来源:MusicUtils.java

示例9: getReleaseDateForAlbum

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param name The name of the album.
 * @return The release date for an album.
 */
public static final String getReleaseDateForAlbum(final Context context, final String name) {
    if (name == null) {
        return null;
    }
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, new String[] {
                AlbumColumns.FIRST_YEAR
            }, AlbumColumns.ALBUM + "=?", new String[] {
                name
            }, AlbumColumns.ALBUM);
    String releaseDate = null;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            releaseDate = cursor.getString(0);
        }
        cursor.close();
        cursor = null;
    }
    return releaseDate;
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:27,代码来源:MusicUtils.java

示例10: makeArtistAlbumCursor

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param artistId The Id of the artist the albums belong to.
 */
public static final Cursor makeArtistAlbumCursor(final Context context, final Long artistId) {
    return context.getContentResolver().query(
            MediaStore.Audio.Artists.Albums.getContentUri("external", artistId), new String[] {
                    /* 0 */
                    BaseColumns._ID,
                    /* 1 */
                    AlbumColumns.ALBUM,
                    /* 2 */
                    AlbumColumns.ARTIST,
                    /* 3 */
                    AlbumColumns.NUMBER_OF_SONGS,
                    /* 4 */
                    AlbumColumns.FIRST_YEAR
            }, null, null, PreferenceUtils.getInstace(context).getArtistAlbumSortOrder());
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:20,代码来源:ArtistAlbumLoader.java

示例11: makeAlbumCursor

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
/**
 * Creates the {@link Cursor} used to run the query.
 * 
 * @param context The {@link Context} to use.
 * @return The {@link Cursor} used to run the album query.
 */
public static final Cursor makeAlbumCursor(final Context context) {
    return context.getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
            new String[] {
                    /* 0 */
                    BaseColumns._ID,
                    /* 1 */
                    AlbumColumns.ALBUM,
                    /* 2 */
                    AlbumColumns.ARTIST,
                    /* 3 */
                    AlbumColumns.NUMBER_OF_SONGS,
                    /* 4 */
                    AlbumColumns.FIRST_YEAR
            }, null, null, PreferenceUtils.getInstace(context).getAlbumSortOrder());
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:22,代码来源:AlbumLoader.java

示例12: getAlbumArtistName

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
public String getAlbumArtistName() {
    synchronized (this) {
        if (mAlbumCursor == null) {
            return null;
        }
        return mAlbumCursor.getString(mAlbumCursor.getColumnIndexOrThrow(AlbumColumns.ARTIST));
    }
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:9,代码来源:MusicService.java

示例13: setHeaderLayout

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
/**
 * @return A custom ContextMenu header
 */
public static  View setHeaderLayout(String Type, Cursor cursor, Activity activity) {
    LayoutInflater inflater = activity.getLayoutInflater();
    View header = inflater.inflate(R.layout.music_context_menu_header, null, false);

    // Artist image
    final ImageView mHanderImage = (ImageView)header.findViewById(R.id.header_image);
    String albumId="",artistName="",albumName="";

    if(Type == TYPE_ALBUM){
        albumName = cursor.getString(cursor.getColumnIndexOrThrow(AlbumColumns.ALBUM));
        artistName = cursor.getString(cursor.getColumnIndexOrThrow(AlbumColumns.ARTIST));
        albumId = cursor.getString(cursor.getColumnIndexOrThrow(BaseColumns._ID));
    }
    else{
        artistName = cursor.getString(cursor.getColumnIndexOrThrow(ArtistColumns.ARTIST));
    }
    
    
    ImageInfo mInfo = new ImageInfo();
    mInfo.type = Type;
    mInfo.size = SIZE_THUMB;
    mInfo.source = SRC_FIRST_AVAILABLE;
    mInfo.data = (Type == TYPE_ALBUM ? new String[]{ albumId , artistName, albumName } : new String[]{ artistName});
   
    ImageProvider.getInstance(activity).loadImage( mHanderImage, mInfo );

    // Set artist name
    TextView headerText = (TextView)header.findViewById(R.id.header_text);
    headerText.setText( (Type == TYPE_ALBUM ? albumName : artistName));
    headerText.setBackgroundColor((activity).getResources().getColor(R.color.transparent_black));
    return header;
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:36,代码来源:ApolloUtils.java

示例14: loadInBackground

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
@Override
  public Cursor loadInBackground() {

      Cursor mediaCursor = getContext().getContentResolver().query(mUri, mProjection, mSelection,
              mSelectionArgs, mSortOrder);
      //Get cursor filled with Audio Id's
      String [] projection =  new String[] {
              BaseColumns._ID, AlbumColumns.ALBUM
      };
      Uri uri = Audio.Albums.EXTERNAL_CONTENT_URI;
      String sortOrder = Audio.Albums.DEFAULT_SORT_ORDER;
      Cursor albumCursor = getContext().getContentResolver().query(uri, projection, null, null, sortOrder);

      //Matrix cursor to hold final data to be returned to calling context
      MatrixCursor cursor = new MatrixCursor( new String[]
      		{ BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ARTIST, AudioColumns.ALBUM, AudioColumns.ALBUM_ID});
      //Map data from Audio Id cursor to the ALbumName Colum
      ContentQueryMap mQueryMap = new ContentQueryMap(albumCursor, AlbumColumns.ALBUM, false, null);

Map<String, ContentValues> data = mQueryMap.getRows();
      if (mediaCursor != null) {
          while(mediaCursor.moveToNext()) {
		String id = mediaCursor.getString(mediaCursor.getColumnIndexOrThrow(BaseColumns._ID));
		String title = mediaCursor.getString(mediaCursor.getColumnIndexOrThrow(MediaColumns.TITLE));
		String artist = mediaCursor.getString(mediaCursor.getColumnIndexOrThrow(AudioColumns.ARTIST));
		String album = mediaCursor.getString(mediaCursor.getColumnIndexOrThrow(AudioColumns.ALBUM));

		ContentValues tData = data.get(album);
		String albumid = (String) tData.get(BaseColumns._ID);
		cursor.addRow(new String[] {id, title, artist, album, albumid});
          }
          mediaCursor.close();
      }

      if (cursor != null) {
          // Ensure the cursor window is filled
          registerContentObserver(cursor, mObserver);
      }
      return cursor;
  }
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:41,代码来源:AddIdCursorLoader.java

示例15: setupFragmentData

import android.provider.MediaStore.Audio.AlbumColumns; //导入依赖的package包/类
public void setupFragmentData(){
	mAdapter = new AlbumAdapter(getActivity(), R.layout.music_gridview_items, null,
            					new String[] {}, new int[] {}, 0); 
	mProjection = new String []{
            BaseColumns._ID, AlbumColumns.ALBUM, AlbumColumns.ARTIST, AlbumColumns.ALBUM_ART
    };
    mUri = Audio.Albums.EXTERNAL_CONTENT_URI;
    mSortOrder = Audio.Albums.DEFAULT_SORT_ORDER;
    mFragmentGroupId = 2;
    mType = TYPE_ALBUM;
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:12,代码来源:AlbumsFragment.java


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