ConnectivityManager with the Android emulator

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

ConnectivityManager with the Android emulator

Postby vladi483 » Mon Dec 08, 2008 6:50 pm

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();

What I get is 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!
vladi483
Freshman
Freshman
 
Posts: 2
Joined: Mon Dec 08, 2008 6:38 pm

Top

Postby vladi483 » Mon Dec 08, 2008 7:29 pm

Pressing key F8 will switch the emulator network connection on/off .

The right action for the IntentFilter is "android.net.conn.CONNECTIVITY_CHANGE".
vladi483
Freshman
Freshman
 
Posts: 2
Joined: Mon Dec 08, 2008 6:38 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 2 guests