Thank you David!

In the meantime I found the right action for the IntentFilter. It is
"android.net.conn.CONNECTIVITY_CHANGE".


On 8 Dez., 18:58, "David Turner" <[EMAIL PROTECTED]> wrote:
> pressing F8 will toggle the emulator network on/off.
>
> On Mon, Dec 8, 2008 at 9:09 AM, nimbus83 <[EMAIL PROTECTED]> wrote:
>
> > 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 {
>
> >               [EMAIL PROTECTED]
> >                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
-~----------~----~----~----~------~----~------~--~---

Reply via email to