views:

47

answers:

2

Hi all, in my android application i want to add the functionality the user to buy song from amazon. The easiest way to do is i think to use amazon mp3 application to communicate with amazon store. I found this piece of code from 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 menu to select where to search for your song (browser, youtube, amazon mp3). But here are some things i want to do -

  1. I don't want to show the whole pop up screen but only amazon search, what intent i should use to search directly in amazon mp3.
  2. How can i send my affiliate partner key to amazon mp3 so it can included it when querying amazon.

Shazam is using directly amazon mp3 but i couldn't find any information what intent i should use. Thanks in advance any help will be very helpful.

A: 

It's not a public API; Shazam apparently have a private arrangement with Amazon. It might be worth contacting Amazon directly, since they have a lot of public APIs, and this one would certainly seem to be in their interests. But like any large company, I wouldn't hold your breath for a response.

Colin Pickard
I'd like to echo Colin's sentiments and add that what Mojo Risin is trying to do is a violation of Amazon's current TOS. They prohibit using their APIs or affliate links to sell via mobile apps unless you get their blessing.
Kevin McMahon
A: 

as for 1., you can try to determine the correct activity by evaulating the list of matching activities like this (i being the intent you created):

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);

This is sort of a hack since one should not rely on the package name starting with a certain fixed string, but in fact it will probably work for long. Just be prepared in your code to deal with it changing (android will automatically display the activity chooser if the Amazon activity is not identified).

as for 2., sorry, I have no information about this.

Thorstenvv