Handles the button click to open the music app - Android android.content.pm

Android examples for android.content.pm:App

Description

Handles the button click to open the music app

Demo Code

import android.app.Activity;
import android.content.Intent;
import android.provider.MediaStore;

public class Main{

    /**//  w  w w  .  java  2  s  .c  o m
     * 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