start Spotify Search - Android App

Android examples for App:Popular App

Description

start Spotify Search

Demo Code


import android.app.SearchManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.provider.MediaStore;

public class Main{
    private static final String SPOTIFY_PACKAGE = "com.spotify.music";
    public static void startSpotifySearch(Context context, String query) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setAction(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
        intent.setComponent(new ComponentName(SPOTIFY_PACKAGE,
                SPOTIFY_PACKAGE + ".MainActivity"));
        intent.putExtra(SearchManager.QUERY, query);
        context.startActivity(intent);/*from   w  w w  . j av  a  2  s .co m*/
    }
}

Related Tutorials