Amazon mp3 integration in Android app

in my android application i want to add user functionality to buy a song from amazon. The easiest way to do this is to use the amazon mp3 app to talk to the amazon store. I found this piece of code from the default music player

Intent i = new Intent();
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH);
i.putExtra(SearchManager.QUERY, mSong.getArtits() + " " + mSong.getName());
i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, "artist");
i.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, "album");
i.putExtra(MediaStore.EXTRA_MEDIA_TITLE, mSong.getName());
i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, "audio/*");
startActivity(Intent.createChooser(i, "Search for " + mSong.getName()));

which shows a menu to choose where to search for your song (browser, youtube, amazon mp3). But here are some things I want to do -

  • I do not want to show the entire pop-up screen, but only Amazon search, which I should use to search directly in amazon mp3.
  • How can I send my partner affiliate key to amazon mp3 so that it can turn it on when requested by amazon.

Shazam amazon mp3, , . , .

+3
2

API; -, . , Amazon , API, , , . , , .

+3

1., , , ( , ):

List<ResolveInfo> info = getPackageManager().queryIntentActivities(i, 0);
String packageName=null, className=null;
for ( ResolveInfo r: info){
    if ( r.activityInfo.packageName.startsWith("com.amazon.mp3")){
        packageName=r.activityInfo.packageName;
        className=r.activityInfo.name;
        break;
    }
}
if ( packageName != null && className != null)
    i.setClassName(packageName, className);
startActivity(i);

, , , , , . , ( , Amazon ).

2., , .

+3

Source: https://habr.com/ru/post/1762462/


All Articles