AndroidRadioDataProviderpublic final class AndroidRadioDataProvider extends android.telephony.PhoneStateListener Radio data provider implementation for Android. |
Fields Summary |
---|
private static final String | TAGLogging tag | private static final int | RADIO_TYPE_UNKNOWNNetwork types | private static final int | RADIO_TYPE_GSM | private static final int | RADIO_TYPE_WCDMA | private long | nativeObjectThe native object ID | private android.telephony.CellLocation | cellLocationThe last known cellLocation | private int | signalStrengthThe last known signal strength | private android.telephony.ServiceState | serviceStateThe last known serviceState | private android.telephony.TelephonyManager | telephonyManagerOur TelephonyManager instance. |
Constructors Summary |
---|
public AndroidRadioDataProvider(android.webkit.WebView webview, long object)Public constructor. Uses the webview to get the Context object.
super();
nativeObject = object;
telephonyManager = (TelephonyManager) webview.getContext().getSystemService(
Context.TELEPHONY_SERVICE);
if (telephonyManager == null) {
Log.e(TAG,
"AndroidRadioDataProvider: could not get tepephony manager.");
throw new NullPointerException(
"AndroidRadioDataProvider: telephonyManager is null.");
}
// Register for cell id, signal strength and service state changed
// notifications.
telephonyManager.listen(this, PhoneStateListener.LISTEN_CELL_LOCATION
| PhoneStateListener.LISTEN_SIGNAL_STRENGTH
| PhoneStateListener.LISTEN_SERVICE_STATE);
|
Methods Summary |
---|
private void | notifyListeners()
RadioData radioData = RadioData.getInstance(telephonyManager, cellLocation,
signalStrength, serviceState);
if (radioData != null) {
onUpdateAvailable(radioData, nativeObject);
}
| public void | onCellLocationChanged(android.telephony.CellLocation location)
cellLocation = location;
notifyListeners();
| public void | onServiceStateChanged(android.telephony.ServiceState state)
serviceState = state;
notifyListeners();
| public void | onSignalStrengthChanged(int asu)
signalStrength = asu;
notifyListeners();
| private static native void | onUpdateAvailable(android.webkit.gears.AndroidRadioDataProvider$RadioData radioData, long nativeObject)The native method called when new radio data is available.
| public void | shutdown()Should be called when the provider is no longer needed.
telephonyManager.listen(this, PhoneStateListener.LISTEN_NONE);
Log.i(TAG, "AndroidRadioDataProvider shutdown.");
|
|