List of usage examples for android.hardware.radio RadioTuner DIRECTION_DOWN
int DIRECTION_DOWN
To view the source code for android.hardware.radio RadioTuner DIRECTION_DOWN.
Click Source Link
From source file:com.google.android.car.kitchensink.radio.RadioTestFragment.java
private void addHandlers() { mOpenRadio.setOnClickListener(new View.OnClickListener() { @Override/* w w w .j a v a 2 s .co m*/ public void onClick(View v) { handleRadioStart(); updateStates(); } }); mCloseRadio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { handleRadioEnd(); mToggleMuteRadio.setChecked(true); updateStates(); } }); mToggleMuteRadio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Toggle mute radio"); } mRadioTuner.setMute(!mRadioTuner.getMute()); updateStates(); } }); mGetRadioFocus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Get radio focus"); } try { mCarAudioManager.requestAudioFocus(mRadioFocusListener, mRadioAudioAttrib, AudioManager.AUDIOFOCUS_GAIN, 0); } catch (CarNotConnectedException e) { //ignore for now } mHasRadioFocus = true; updateStates(); } }); mReleaseRadioFocus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Release radio focus"); } mCarAudioManager.abandonAudioFocus(mRadioFocusListener, mRadioAudioAttrib); mHasRadioFocus = false; updateStates(); } }); mGetFocus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Get secondary focus"); } mAudioManager.requestAudioFocus(mSecondaryFocusListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); mHasSecondaryFocus = true; updateStates(); } }); mReleaseFocus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Release secondary focus"); } mAudioManager.abandonAudioFocus(mSecondaryFocusListener); mHasSecondaryFocus = false; updateStates(); } }); mRadioNext.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Next radio station"); } if (mRadioTuner != null) { mRadioTuner.scan(RadioTuner.DIRECTION_UP, true); } updateStates(); } }); mRadioPrev.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Previous radio station"); } if (mRadioTuner != null) { mRadioTuner.scan(RadioTuner.DIRECTION_DOWN, true); } updateStates(); } }); mRadioScanCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Cancel radio scan"); } if (mRadioTuner != null) { mRadioTuner.cancel(); } updateStates(); } }); mRadioTuneToStation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Tuning to station"); } String station = mStationFrequency.getText().toString().trim(); if (mRadioTuner != null && !(station.equals(""))) { mRadioTuner.tune(Integer.parseInt(station), 0); } resetMessages(); updateMessages(); updateStates(); } }); mRadioStepUp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Step up"); } if (mRadioTuner != null) { mRadioTuner.step(RadioTuner.DIRECTION_UP, false); } resetMessages(); updateMessages(); updateStates(); } }); mRadioStepDown.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "Step down"); } if (mRadioTuner != null) { mRadioTuner.step(RadioTuner.DIRECTION_DOWN, false); } resetMessages(); updateMessages(); updateStates(); } }); mRadioGetProgramInfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (DBG) { Log.i(TAG, "getProgramInformation"); } if (mRadioTuner != null) { RadioManager.ProgramInfo[] programInfos = new RadioManager.ProgramInfo[1]; mRadioTuner.getProgramInformation(programInfos); addLog(Log.INFO, "mRadioTuner.getProgramInformation() =>" + programInfos[0]); } } }); mRadioBand.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (DBG) { Log.i(TAG, "Changing radio band"); } if (mRadioTuner != null) { mRadioTuner.setConfiguration(mRadioBand.isChecked() ? mFmConfig : mAmConfig); } resetMessages(); updateMessages(); updateStates(); } }); }