Hi,

I tried by capturing the status through BroadcastReceiver.
But the application crashes when i try to change the network status.
On the other hand when i switch off and on the phone, the connection
status
is captured successfully.
Can anyone help what wrong i am doing.

Please find  the code snippet below:
public class ConnectionChangeReceiver extends BroadcastReceiver {

        @Override
        public void onReceive(Context context, Intent intent) {

        ConnectivityManager connectivityManager =
        (ConnectivityManager) context.getSystemService
(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo
();
        NetworkInfo mobNetInfo = connectivityManager.getNetworkInfo
(ConnectivityManager.TYPE_MOBILE);
        Toast.makeText(context,"Active Network Type : " +
activeNetInfo.getTypeName() , Toast.LENGTH_SHORT).show();
        Toast.makeText(context,"Mobile Network Type : " +
mobNetInfo.getTypeName() , Toast.LENGTH_SHORT).show();
        }

}

AndroidManifest.xml

 <uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE" />
      <uses-permission android:name="android.permission.INTERNET" />
      <!-- Network Monitor Application -->
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <receiver android:name=".ConnectionChangeReceiver"
        android:enabled="true"
        android:priority="0" >
         <intent-filter>
                <action
android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </intent-filter>
            </receiver>

    </application>

Thanks in advance for any information!!

Regards,
Prince
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to