Example usage for android.media AudioManager STREAM_NOTIFICATION

List of usage examples for android.media AudioManager STREAM_NOTIFICATION

Introduction

In this page you can find the example usage for android.media AudioManager STREAM_NOTIFICATION.

Prototype

int STREAM_NOTIFICATION

To view the source code for android.media AudioManager STREAM_NOTIFICATION.

Click Source Link

Document

Used to identify the volume of audio streams for notifications

Usage

From source file:jmri.enginedriver.throttle.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case ACTIVITY_SELECT_LOCO:
        if (resultCode == select_loco.RESULT_LOCO_EDIT)
            ActivityConsistUpdate(resultCode, data.getExtras());
        if ((getConsist(whichVolume) != null) && (!getConsist(whichVolume).isActive())) {
            setNextActiveThrottle(); // if consist on Volume throttle was released, move to next throttle
        } else {//w ww .  j a v a 2  s  .  c  o m
            if (IS_ESU_MCII) {
                esuMc2Led.setState(EsuMc2Led.GREEN, EsuMc2LedState.STEADY_FLASH, true);
            }
            setActiveThrottle(whichVolume);
        }
        break;
    case ACTIVITY_CONSIST: // edit loco or edit consist
        if (resultCode == ConsistEdit.RESULT_CON_EDIT)
            ActivityConsistUpdate(resultCode, data.getExtras());
        break;
    case ACTIVITY_CONSIST_LIGHTS: // edit consist lights
        break; // nothing to do
    case ACTIVITY_PREFS: { // edit prefs
        if (resultCode == preferences.RESULT_GAMEPAD) { // gamepad pref changed
            // update tone generator volume
            if (tg != null) {
                tg.release();
                try {
                    tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION,
                            preferences.getIntPrefValue(prefs, "prefGamePadFeedbackVolume",
                                    getApplicationContext().getResources()
                                            .getString(R.string.prefGamePadFeedbackVolumeDefaultValue)));
                } catch (RuntimeException e) {
                    Log.e("Engine_Driver", "new ToneGenerator failed. Runtime Exception, OS "
                            + android.os.Build.VERSION.SDK_INT + " Message: " + e);
                }
            }
            // update GamePad Support
            setGamepadKeys();
        }
        if (resultCode == preferences.RESULT_ESUMCII) { // ESU MCII pref change
            // update zero trim values
            updateEsuMc2ZeroTrim();
        }
        // in case the preference has changed but the current screen does not support the number selected.
        setThottleNumLimits();

        getKidsTimerPrefs();
        if (prefKidsTimer.equals(PREF_KIDS_TIMER_NONE)) {
            kidsTimerActions(KIDS_TIMER_DISABLED, 0);
        }

        break;
    }
    case ACTIVITY_GAMEPAD_TEST: {
        if (data != null) {
            String whichGamepadNo = data.getExtras().getString("whichGamepadNo");
            if (whichGamepadNo != null) {
                int result = Integer.valueOf(whichGamepadNo.substring(1, 2));
                int gamepadNo = Integer.valueOf(whichGamepadNo.substring(0, 1));
                switch (result) {
                case GAMEPAD_TEST_PASS:
                    gamePadDeviceIdsTested[gamepadNo] = GAMEPAD_GOOD;
                    speakWords(TTS_MSG_GAMEPAD_GAMEPAD_TEST_COMPLETE, ' ');
                    break;
                case GAMEPAD_TEST_SKIPPED:
                    gamePadDeviceIdsTested[gamepadNo] = GAMEPAD_GOOD;
                    speakWords(TTS_MSG_GAMEPAD_GAMEPAD_TEST_SKIPPED, ' ');
                    break;
                case GAMEPAD_TEST_FAIL:
                    gamePadDeviceIdsTested[gamepadNo] = GAMEPAD_BAD;
                    speakWords(TTS_MSG_GAMEPAD_GAMEPAD_TEST_FAIL, ' ');
                    break;
                case GAMEPAD_TEST_RESET:
                    gamepadCount = 0;
                    for (int i = 0; i < gamePadDeviceIds.length; i++) {
                        gamePadDeviceIds[i] = 0;
                        gamePadDeviceIdsTested[i] = 0;
                    }
                    for (int i = 0; i < 3; i++) {
                        gamePadIds[i] = 0;
                        gamePadThrottleAssignment[0] = -1;
                    }
                    mainapp.setGamepadTestMenuOption(TMenu, gamepadCount);
                    setGamepadIndicator();
                    speakWords(TTS_MSG_GAMEPAD_GAMEPAD_TEST_RESET, ' ');
                    break;
                default:
                    Log.e("Engine_Driver", "OnActivityResult(ACTIVITY_GAMEPAD_TEST) invalid result!");
                }
            }
        } else {
            Log.e("Engine_Driver", "OnActivityResult(ACTIVITY_GAMEPAD_TEST) called with null data!");
        }
        break;
    }
    }

    // loop through all function buttons and
    // set label and dcc functions (based on settings) or hide if no label
    setAllFunctionLabelsAndListeners();
    set_labels();

}