List of usage examples for android.provider MediaStore EXTRA_MEDIA_ALBUM
String EXTRA_MEDIA_ALBUM
To view the source code for android.provider MediaStore EXTRA_MEDIA_ALBUM.
Click Source Link
From source file:org.musicmod.android.app.QueryFragment.java
public void onServiceConnected(ComponentName name, IBinder service) { Bundle bundle = getArguments();/*from w ww . j av a 2 s. c o m*/ String action = bundle != null ? bundle.getString(INTENT_KEY_ACTION) : null; String data = bundle != null ? bundle.getString(INTENT_KEY_DATA) : null; if (Intent.ACTION_VIEW.equals(action)) { // this is something we got from the search bar Uri uri = Uri.parse(data); if (data.startsWith("content://media/external/audio/media/")) { // This is a specific file String id = uri.getLastPathSegment(); long[] list = new long[] { Long.valueOf(id) }; MusicUtils.playAll(getActivity(), list, 0); getActivity().finish(); return; } else if (data.startsWith("content://media/external/audio/albums/")) { // This is an album, show the songs on it Intent i = new Intent(Intent.ACTION_PICK); i.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track"); i.putExtra("album", uri.getLastPathSegment()); startActivity(i); return; } else if (data.startsWith("content://media/external/audio/artists/")) { // This is an artist, show the albums for that artist Intent i = new Intent(Intent.ACTION_PICK); i.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/album"); i.putExtra("artist", uri.getLastPathSegment()); startActivity(i); return; } } mFilterString = bundle != null ? bundle.getString(SearchManager.QUERY) : null; if (MediaStore.INTENT_ACTION_MEDIA_SEARCH.equals(action)) { String focus = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_FOCUS) : null; String artist = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_ARTIST) : null; String album = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_ALBUM) : null; String title = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_TITLE) : null; if (focus != null) { if (focus.startsWith("audio/") && title != null) { mFilterString = title; } else if (Audio.Albums.ENTRY_CONTENT_TYPE.equals(focus)) { if (album != null) { mFilterString = album; if (artist != null) { mFilterString = mFilterString + " " + artist; } } } else if (Audio.Artists.ENTRY_CONTENT_TYPE.equals(focus)) { if (artist != null) { mFilterString = artist; } } } } mTrackList = getListView(); mTrackList.setTextFilterEnabled(true); }
From source file:com.andrew.apolloMod.activities.QueryBrowserActivity.java
@Override public void onServiceConnected(ComponentName name, IBinder service) { if (mAdapter != null) { getQueryCursor(mAdapter.getQueryHandler(), null); }/* w w w . j a v a 2s. co m*/ Intent intent = getIntent(); String action = intent != null ? intent.getAction() : null; if (Intent.ACTION_VIEW.equals(action)) { // this is something we got from the search bar Uri uri = intent.getData(); String path = uri.toString(); if (path.startsWith("content://media/external/audio/media/")) { // This is a specific file String id = uri.getLastPathSegment(); long[] list = new long[] { Long.valueOf(id) }; MusicUtils.playAll(this, list, 0); finish(); return; } else if (path.startsWith("content://media/external/audio/albums/")) { // This is an album, show the songs on it Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track"); i.putExtra("album", uri.getLastPathSegment()); startActivity(i); finish(); return; } else if (path.startsWith("content://media/external/audio/artists/")) { intent = new Intent(Intent.ACTION_VIEW); Bundle bundle = new Bundle(); bundle.putString(MIME_TYPE, Audio.Artists.CONTENT_TYPE); bundle.putString(ARTIST_KEY, uri.getLastPathSegment()); bundle.putLong(BaseColumns._ID, ApolloUtils.getArtistId(uri.getLastPathSegment(), ARTIST_ID, this)); intent.setClass(this, TracksBrowser.class); intent.putExtras(bundle); startActivity(intent); return; } } mFilterString = intent.getStringExtra(SearchManager.QUERY); if (MediaStore.INTENT_ACTION_MEDIA_SEARCH.equals(action)) { String focus = intent.getStringExtra(MediaStore.EXTRA_MEDIA_FOCUS); String artist = intent.getStringExtra(MediaStore.EXTRA_MEDIA_ARTIST); String album = intent.getStringExtra(MediaStore.EXTRA_MEDIA_ALBUM); String title = intent.getStringExtra(MediaStore.EXTRA_MEDIA_TITLE); if (focus != null) { if (focus.startsWith("audio/") && title != null) { mFilterString = title; } else if (focus.equals(Audio.Albums.ENTRY_CONTENT_TYPE)) { if (album != null) { mFilterString = album; if (artist != null) { mFilterString = mFilterString + " " + artist; } } } else if (focus.equals(Audio.Artists.ENTRY_CONTENT_TYPE)) { if (artist != null) { mFilterString = artist; } } } } setContentView(R.layout.listview); mTrackList = getListView(); mTrackList.setTextFilterEnabled(true); if (mAdapter == null) { mAdapter = new QueryListAdapter(getApplication(), this, R.layout.listview_items, null, // cursor new String[] {}, new int[] {}, 0); setListAdapter(mAdapter); if (TextUtils.isEmpty(mFilterString)) { getQueryCursor(mAdapter.getQueryHandler(), null); } else { mTrackList.setFilterText(mFilterString); mFilterString = null; } } else { mAdapter.setActivity(this); setListAdapter(mAdapter); mQueryCursor = mAdapter.getCursor(); if (mQueryCursor != null) { init(mQueryCursor); } else { getQueryCursor(mAdapter.getQueryHandler(), mFilterString); } } LinearLayout emptyness = (LinearLayout) findViewById(R.id.empty_view); emptyness.setVisibility(View.GONE); }
From source file:org.runbuddy.tomahawk.utils.MediaPlayIntentHandler.java
public void mediaPlayFromSearch(Bundle extras) { mWaitingGenre = null;/*ww w. j a va2 s . com*/ mCorrespondingQueries.clear(); mCorrespondingRequestIds.clear(); mResolvingAlbum = null; mResolvingArtist = null; String mediaFocus = extras.getString(MediaStore.EXTRA_MEDIA_FOCUS); String query = extras.getString(SearchManager.QUERY); // Some of these extras may not be available depending on the search mode String album = extras.getString(MediaStore.EXTRA_MEDIA_ALBUM); String artist = extras.getString(MediaStore.EXTRA_MEDIA_ARTIST); final String genre = extras.getString("android.intent.extra.genre"); String playlist = extras.getString("android.intent.extra.playlist"); String title = extras.getString(MediaStore.EXTRA_MEDIA_TITLE); // Determine the search mode and use the corresponding extras if (mediaFocus == null) { // 'Unstructured' search mode (backward compatible) Query q = Query.get(query, false); mCorrespondingQueries.clear(); mCorrespondingQueries.add(PipeLine.get().resolve(q)); } else if (mediaFocus.compareTo("vnd.android.cursor.item/*") == 0) { if (query != null && query.isEmpty()) { // 'Any' search mode CollectionManager.get().getUserCollection().getQueries(Collection.SORT_ALPHA) .done(new DoneCallback<Playlist>() { @Override public void onDone(Playlist collectionTracks) { playPlaylist(collectionTracks, true); } }); } else { // 'Unstructured' search mode Query q = Query.get(query, false); mCorrespondingQueries.add(PipeLine.get().resolve(q)); } } else if (mediaFocus.compareTo(MediaStore.Audio.Genres.ENTRY_CONTENT_TYPE) == 0) { // 'Genre' search mode mWaitingGenre = genre; playGenre(); } else if (mediaFocus.compareTo(MediaStore.Audio.Artists.ENTRY_CONTENT_TYPE) == 0) { // 'Artist' search mode final Artist a = Artist.get(artist); CollectionManager.get().getUserCollection().getArtistTracks(a).done(new DoneCallback<Playlist>() { @Override public void onDone(Playlist result) { if (result != null && result.size() > 0) { // There are some local tracks for the requested artist available playPlaylist(result, false); } else { // Try fetching top-hits for the requested artist mResolvingArtist = a; mCorrespondingRequestIds.add(InfoSystem.get().resolve(a, true)); } } }); } else if (mediaFocus.compareTo(MediaStore.Audio.Albums.ENTRY_CONTENT_TYPE) == 0) { // 'Album' search mode final Album a = Album.get(album, Artist.get(artist)); CollectionManager.get().getUserCollection().getAlbumTracks(a).done(new DoneCallback<Playlist>() { @Override public void onDone(Playlist result) { if (result != null && result.size() > 0) { // There are some local tracks for the requested album available playPlaylist(result, false); } else { // Try fetching top-hits for the requested album mResolvingAlbum = a; mCorrespondingRequestIds.add(InfoSystem.get().resolve(a)); } } }); } else if (mediaFocus.compareTo("vnd.android.cursor.item/audio") == 0) { // 'Song' search mode Query q = Query.get(title, album, artist, false); mCorrespondingQueries.add(PipeLine.get().resolve(q)); } else if (mediaFocus.compareTo(MediaStore.Audio.Playlists.ENTRY_CONTENT_TYPE) == 0) { // 'Playlist' search mode Playlist bestMatch = null; float bestScore = 0f; float minScore = 0.7f; for (Playlist pl : DatabaseHelper.get().getPlaylists()) { float score = ResultScoring.calculateScore(pl.getName(), playlist); if (score > minScore && score > bestScore) { bestMatch = pl; bestScore = score; } } if (bestMatch != null) { playPlaylist(bestMatch, false); } } }
From source file:org.yammp.fragment.QueryFragment.java
public void onServiceConnected(ComponentName name, IBinder service) { Bundle bundle = getArguments();// ww w . ja v a 2 s . c o m String action = bundle != null ? bundle.getString(INTENT_KEY_ACTION) : null; String data = bundle != null ? bundle.getString(INTENT_KEY_DATA) : null; if (Intent.ACTION_VIEW.equals(action)) { // this is something we got from the search bar Uri uri = Uri.parse(data); if (data.startsWith("content://media/external/audio/media/")) { // This is a specific file String id = uri.getLastPathSegment(); long[] list = new long[] { Long.valueOf(id) }; mUtils.playAll(list, 0); getActivity().finish(); return; } else if (data.startsWith("content://media/external/audio/albums/")) { // This is an album, show the songs on it Intent i = new Intent(Intent.ACTION_PICK); i.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track"); i.putExtra("album", uri.getLastPathSegment()); startActivity(i); return; } else if (data.startsWith("content://media/external/audio/artists/")) { // This is an artist, show the albums for that artist Intent i = new Intent(Intent.ACTION_PICK); i.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/album"); i.putExtra("artist", uri.getLastPathSegment()); startActivity(i); return; } } mFilterString = bundle != null ? bundle.getString(SearchManager.QUERY) : null; if (MediaStore.INTENT_ACTION_MEDIA_SEARCH.equals(action)) { String focus = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_FOCUS) : null; String artist = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_ARTIST) : null; String album = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_ALBUM) : null; String title = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_TITLE) : null; if (focus != null) { if (focus.startsWith("audio/") && title != null) { mFilterString = title; } else if (Audio.Albums.ENTRY_CONTENT_TYPE.equals(focus)) { if (album != null) { mFilterString = album; if (artist != null) { mFilterString = mFilterString + " " + artist; } } } else if (Audio.Artists.ENTRY_CONTENT_TYPE.equals(focus)) { if (artist != null) { mFilterString = artist; } } } } mTrackList = getListView(); mTrackList.setTextFilterEnabled(true); }
From source file:org.yammp.app.AlbumFragment.java
private void doSearch() { CharSequence title = null;//from w ww.java2s . com String query = null; Intent i = new Intent(); i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); title = mCurrentAlbumName; if (MediaStore.UNKNOWN_STRING.equals(mCurrentArtistNameForAlbum)) { query = mCurrentAlbumName; } else { query = mCurrentArtistNameForAlbum + " " + mCurrentAlbumName; i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, mCurrentArtistNameForAlbum); } if (MediaStore.UNKNOWN_STRING.equals(mCurrentAlbumName)) { i.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, mCurrentAlbumName); } i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, "audio/*"); title = getString(R.string.mediasearch, title); i.putExtra(SearchManager.QUERY, query); startActivity(Intent.createChooser(i, title)); }
From source file:de.bahnhoefe.deutschlands.bahnhofsfotos.DetailsActivity.java
public void takePicture() { if (!canSetPhoto()) { return;/*from w w w . j av a2 s.c o m*/ } if (isMyDataIncomplete()) { checkMyData(); } else { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = getCameraMediaFile(); if (file != null) { Uri photoURI = FileProvider.getUriForFile(this, "de.bahnhoefe.deutschlands.bahnhofsfotos.fileprovider", file); intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); intent.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, getResources().getString(R.string.app_name)); intent.putExtra(MediaStore.EXTRA_MEDIA_TITLE, bahnhof.getTitle()); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); startActivityForResult(intent, REQUEST_TAKE_PICTURE); } else { Toast.makeText(this, R.string.unable_to_create_folder_structure, Toast.LENGTH_LONG).show(); } } }
From source file:org.yammp.fragment.ArtistFragment.java
private void doSearch(String artist, String album) { CharSequence title = null;// w ww. ja v a2 s . c o m String query = null; boolean isUnknownArtist = artist == null || MediaStore.UNKNOWN_STRING.equals(artist); boolean isUnknownAlbum = album == null || MediaStore.UNKNOWN_STRING.equals(album); if (isUnknownArtist && isUnknownAlbum) return; Intent i = new Intent(); i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); title = album != null ? album : artist; query = album != null ? album : artist; if (!isUnknownArtist) { i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, artist); } if (!isUnknownAlbum) { i.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, album); } i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, "audio/*"); title = getString(R.string.mediasearch, title); i.putExtra(SearchManager.QUERY, query); startActivity(Intent.createChooser(i, title)); }
From source file:org.musicmod.android.app.MusicPlaybackActivity.java
@Override public boolean onLongClick(View v) { // TODO search media info String track = getTitle().toString(); String artist = "";// mArtistNameView.getText().toString(); String album = "";// mAlbumNameView.getText().toString(); CharSequence title = getString(R.string.mediasearch, track); Intent i = new Intent(); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH); i.putExtra(MediaStore.EXTRA_MEDIA_TITLE, track); String query = track;// ww w . java 2 s . co m if (!getString(R.string.unknown_artist).equals(artist) && !getString(R.string.unknown_album).equals(album)) { query = artist + " " + track; i.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, album); i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, artist); } else if (getString(R.string.unknown_artist).equals(artist) && !getString(R.string.unknown_album).equals(album)) { query = album + " " + track; i.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, album); } else if (!getString(R.string.unknown_artist).equals(artist) && getString(R.string.unknown_album).equals(album)) { query = artist + " " + track; i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, artist); } i.putExtra(SearchManager.QUERY, query); i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, "audio/*"); startActivity(Intent.createChooser(i, title)); return true; }
From source file:com.android.music.ArtistAlbumBrowserFragment.java
void doSearch() { CharSequence title = null;//from w w w. j a va2s. c o m String query = null; Intent i = new Intent(); i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (mCurrentArtistId != null) { title = mCurrentArtistName; query = mCurrentArtistName; i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, mCurrentArtistName); i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, MediaStore.Audio.Artists.ENTRY_CONTENT_TYPE); } else { if (mIsUnknownAlbum) { title = query = mCurrentArtistNameForAlbum; } else { title = query = mCurrentAlbumName; if (!mIsUnknownArtist) { query = query + " " + mCurrentArtistNameForAlbum; } } i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, mCurrentArtistNameForAlbum); i.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, mCurrentAlbumName); i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, MediaStore.Audio.Albums.ENTRY_CONTENT_TYPE); } title = getString(R.string.mediasearch, title); i.putExtra(SearchManager.QUERY, query); startActivity(Intent.createChooser(i, title)); }
From source file:com.android.music.AlbumBrowserActivity.java
void doSearch() { CharSequence title = null;//from ww w.ja v a 2 s.c om String query = ""; Intent i = new Intent(); i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); title = ""; if (!mIsUnknownAlbum) { query = mCurrentAlbumName; i.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, mCurrentAlbumName); title = mCurrentAlbumName; } if (!mIsUnknownArtist) { query = query + " " + mCurrentArtistNameForAlbum; i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, mCurrentArtistNameForAlbum); title = title + " " + mCurrentArtistNameForAlbum; } // Since we hide the 'search' menu item when both album and artist are // unknown, the query and title strings will have at least one of those. i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, MediaStore.Audio.Albums.ENTRY_CONTENT_TYPE); title = getString(R.string.mediasearch, title); i.putExtra(SearchManager.QUERY, query); startActivity(Intent.createChooser(i, title)); }