Hello,
I want to implement with the emulator an application that receives
information when the network connection is connected or disconnected.
How can I register a receiver that gets the changes in the network
connection?
I have tried this:
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);
}
}
IntentFilter intentFilter = new IntentFilter();
registerReceiver(new
ConnectionChangeReceiver(), intentFilter);
What should be the input of the filter so that the ConnectivityManager
sends information to my receiver?
And one more question.
I have done some tests with the emulator with the following code:
ConnectivityManager connManager = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connManager.getActiveNetworkInfo();
I get the information that the MOBILE network type is available and
its state is CONNECTED. If I disable the local area connection on my
PC I get the same information. How can make the network information
change? How can I disable/enable the connection for simulations?
Thank you in advance.
Best wishes!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---