Example usage for android.provider MediaStore INTENT_ACTION_MUSIC_PLAYER

List of usage examples for android.provider MediaStore INTENT_ACTION_MUSIC_PLAYER

Introduction

In this page you can find the example usage for android.provider MediaStore INTENT_ACTION_MUSIC_PLAYER.

Prototype

String INTENT_ACTION_MUSIC_PLAYER

To view the source code for android.provider MediaStore INTENT_ACTION_MUSIC_PLAYER.

Click Source Link

Document

Activity Action: Launch a music player.

Usage

From source file:com.saulcintero.moveon.MainHolder.java

@SuppressLint("InlinedApi")
@SuppressWarnings("deprecation")
@Override//from ww  w.  ja  va 2s. c o m
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.coach:
        Intent i = new Intent("android.intent.action.PRACTICE_BUTTONS_STATUS");
        if (!prefs.getBoolean("blocked", false)) {
            boolean speak = prefs.getBoolean("speak", false);
            if (speak) {
                SharedPreferences.Editor editor = prefs.edit();
                editor.putBoolean("speak", false);
                editor.commit();

                TextToSpeechUtils.setSpeak(false);
            } else {
                SharedPreferences.Editor editor = prefs.edit();
                editor.putBoolean("speak", true);
                editor.commit();

                TextToSpeechUtils.setSpeak(true);
            }
            i.putExtra("practiceButtonsStatus", "1");
            sendBroadcast(i);
        }
        break;
    case R.id.camera:
        Intent i2 = new Intent("android.intent.action.TAKE_PICTURE");
        if (!prefs.getBoolean("blocked", false) && MoveOnService.getIsPracticeRunning()) {
            sendBroadcast(i2);
        }
        break;
    case R.id.padlock:
        changeLockedStatus();

        Intent i3 = new Intent("android.intent.action.PRACTICE_BUTTONS_STATUS");
        i3.putExtra("practiceButtonsStatus", "2");
        sendBroadcast(i3);
        break;
    case R.id.music:
        if (!prefs.getBoolean("blocked", false)) {
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
                startActivity(new Intent(MediaStore.INTENT_ACTION_MUSIC_PLAYER));
            } else {
                Intent intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_MUSIC);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            }
        }
        break;
    case R.id.settings:
        if (!prefs.getBoolean("blocked", false))
            startActivity(new Intent(this, MoveOnPreferences.class));
        break;
    }
    return true;
}