Tuner Range And Region
The minimum and maximum frequency of a modulation supported by the cell phone's radio can be retrieved using TunerControl's getMinFreq() and getMaxFreq() methods. Keep in mind that the frequency returned is in units of 100 Hertz. To convert it to MHz, divide the value by 10,000; for instance, 879,000 in 100 Hertz ~ 87.9 MHz:
int minFreq = tunerControl.getMinFreq (TunerControl.MODULATION_FM); int maxFreq = tunerControl.getMaxFreq (TunerControl.MODULATION_FM);
Similarly for AM modulation:
int minFreq = tunerControl.getMinFreq (TunerControl.MODULATION_AM); int maxFreq = tunerControl.getMaxFreq (TunerControl.MODULATION_AM);
Some applications may need to know which region the radio is equipped for:
if ((minFreq<=879000) && (maxFreq>=1079000)) tuningRegion= "US"; if ((minFreq<=879000) && (maxFreq>=1080000)) tuningRegion="Europe"; if ((minFreq<=760000) && (maxFreq>=900000)) tuningRegion="Japan";
Low-Signal Strength
There may be times when radio reception is substandard, such as when users go underground or between buildings. In such cases, radio reception can be hazy and the audio fuzzy. Luckily, there are parameters you can control to make the reception clearer and more audible. However, you first need to detect the signal strength. Fortunately, this information is easily obtained using TunerControl's getSignalStrength(). The signal strength indicator ranges from 0-100, with 0 being no reception and 100 being the best. For instance, to trigger corrective measures when the signal strength falls below 50 percent:
if (tunerControl .getSignalStrength()<50) { ... }
When the application determines that the reception is not acceptable, you can switch the stereo reception off and go to mono. This prevents the "wobbling" effect as the left and right channels drop off alternately. Do the switch using TunerControl's setStereoMode() method with the parameter TunerControl.MONO:
tunerControl.setStereoMode (TunerControl.MONO);
When the reception is weak, the volume tends to fade and becomes soft as well. To counteract this, you can have the application boost the volume. There are two basic approaches you can takeboosting the volume to the maximum, or incrementing it from the current volume setting. In either case, the first thing you have to do is get the MMAPI volume control of the radio player if it was not created earlier:
VolumeControl volumeControl = (VolumeControl)radioplayer. getControl"VolumeControl");
Once you have the volume control, you can read the current volume level. This ranges from 0-100 with 100 being the loudest and 0 being mute. Thus, to increment the volume, you add a positive numeric value to the current volume level:
int currentVolume = volumeControl.getLevel(); currentVolume = volumeControl.setLevel (currentVolume + 10);
Or if we are just setting the volume to maximum:
int currentVolume = volumeControl.setLevel(100);
Combining all the previous actions, the end result is:
if (tunerControl. getSignalStrength()<50) { tunerControl.setStereoMode (TunerControl.MONO); int currentVolume = volumeControl.getLevel(); currentVolume = volumeControl.setLevel (currentVolume + 10); }