Sunday, February 27, 2011

[android-developers] Re: Android 2.3: Music content providers for artists, albums and songs

I would suggest these two intents for starting artist and album
activities on an Android device now. They also work for Android 2.3
and 3.0.
They do not look as good as the other activities build by Google but
they work :-).

For artists:
String query = "";
Intent intent = new Intent();
intent.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
query = artistName;
intent.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, artistName);
intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS,
MediaStore.Audio.Albums.ENTRY_CONTENT_TYPE);
intent.putExtra(SearchManager.QUERY, query);
mContext.startActivity(intent);

For albums:
Intent intent;
String query = "";
intent = new Intent();
intent.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
query = albumName;
intent.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, albumName);
query = query + " " + artistName;
intent.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, artistName);
intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS,
MediaStore.Audio.Albums.ENTRY_CONTENT_TYPE);
intent.putExtra(SearchManager.QUERY, query);
mContext.startActivity(intent);

On 27 Feb., 08:26, Dianne Hackborn <hack...@android.com> wrote:
> It is a bug that the activity choose allows activities to be launched from
> itself instead of the original caller.  This will be fixed in a future
> release.
>
> On Sat, Feb 26, 2011 at 10:11 PM, gizmomogwai
> <christian.koest...@gmail.com>wrote:
>
>
>
>
>
>
>
>
>
> > Ok ... I understand, that this Intent is not supposed to use that way.
> > My actual question now is, why the behavior of the system changes depending
> > of the installed or not installed MixZing-App.
> > Case 1 (no MixZing):
> > - startActivity leads to an securityexception
> > Case 2 (with MixZing installed):
> > - startActivity opens up the ActivitiyChooser as usual (with Music and
> > MixZing, because they both filter this intent).
> > - choosing the stock music player opens up the music.app with the album
> > preselected (no securityexception).
>
> > thanks in advance
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscribe@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment