0

I'd like to calculate the following number:

CellularServiceChangeRate

Wich indicates how frequently the cellular service the user is connected to changes over a certain period of time.

I'm having some trouble in finding a good Event in the android.telephony API to listen to which would permit me to determine if:

lastAntenna != currentAntenna.

Do you have any suggestions on how to determine this?

ndrizza
  • 3,285
  • 6
  • 27
  • 41

1 Answers1

0

You could setup a Listener for connection change and save the last known cell network in sharedPreferences or save it to the local database

<receiver android="YourNetworkListener">
    <intent-filter>
        <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />

Check the previous connection with

    SharedPreferences sharedPref = getSharedPreferences("name",MODE_PRIVATE);
    String connection = sharedPref.getString("phone_connection", null);

Compare it with the current connection and do the math for your variable and then

Save it

    SharedPreferences sharedPref = getSharedPreferences("name",MODE_PRIVATE);
    SharedPreferences.Editor prefEditor = sharedPref.edit();
    prefEditor.putString("phone_connection", How Ever You want to identify the networks);
    prefEditor.commit();
Darussian
  • 1,573
  • 1
  • 16
  • 28
  • thanks! this has led me to the right path. this question gives also more details about how to react to the broadcast event: http://stackoverflow.com/questions/1783117/network-listener-android – ndrizza Mar 13 '13 at 16:27
  • (too bad there is no listener interface as in with many other sensors) – ndrizza Mar 13 '13 at 16:29