Create Intent to open music - Android Intent

Android examples for Intent:Open App

Description

Create Intent to open music

Demo Code


//package com.java2s;
import android.app.Activity;
import android.content.Intent;
import android.provider.MediaStore;

public class Main {
    /**//  ww w . j a v a  2  s.c  om
     * onClick handler for the openMusicButton.
     * 
     * Handles the button click to open the music app.
     */
    public static void openMusic(Activity context) {

        // Note: Despite being deprecated, new new way doesn't yet work.
        // new Intent(Intent.CATEGORY_APP_MUSIC);
        Intent musicIntent = new Intent(
                MediaStore.INTENT_ACTION_MUSIC_PLAYER);
        context.startActivity(musicIntent);
    }
}

Related Tutorials