List of usage examples for android.content Context RADIO_SERVICE
String RADIO_SERVICE
To view the source code for android.content Context RADIO_SERVICE.
Click Source Link
From source file:com.google.android.car.kitchensink.radio.RadioTestFragment.java
private void initializeRadio() { mRadioManager = (RadioManager) getContext().getSystemService(Context.RADIO_SERVICE); if (mRadioManager == null) { throw new IllegalStateException("RadioManager could not be loaded."); }//w w w . ja va2 s .c om int status = mRadioManager.listModules(mModules); if (status != RadioManager.STATUS_OK) { throw new IllegalStateException("Load modules failed with status: " + status); } if (mModules.size() == 0) { throw new IllegalStateException("No radio modules on device."); } boolean isDebugLoggable = Log.isLoggable(TAG, Log.DEBUG); // Load the possible radio bands. For now, just accept FM and AM bands. for (RadioManager.BandDescriptor band : mModules.get(0).getBands()) { if (isDebugLoggable) { Log.d(TAG, "loading band: " + band.toString()); } if (mFmDescriptor == null && band.isFmBand()) { mFmDescriptor = (RadioManager.FmBandDescriptor) band; } if (mAmDescriptor == null && band.isAmBand()) { mAmDescriptor = (RadioManager.AmBandDescriptor) band; } } if (mFmDescriptor == null && mAmDescriptor == null) { throw new IllegalStateException("No AM and FM radio bands could be loaded."); } mFmConfig = new RadioManager.FmBandConfig.Builder(mFmDescriptor).setStereo(true).build(); mAmConfig = new RadioManager.AmBandConfig.Builder(mAmDescriptor).setStereo(true).build(); }