Try this out. I don't recommend using this as is. You'll want to register a 
receiver for this intent while your app is being used and then unregister it 
when you are done. This is just so you can see how it works.

public class TestService extends BroadcastReceiver
{
    @Override
    public void onReceive(Context context, Intent intent)
    {
        if( intent.getAction().equals( 
"android.net.conn.CONNECTIVITY_CHANGE" ) )
        {
            Log.i( "TestService", "android.net.conn.CONNECTIVITY_CHANGE" );
            NetworkInfo niCommon = intent.getParcelableExtra( 
ConnectivityManager.EXTRA_NETWORK_INFO );

            if( niCommon != null )
            {
                Log.i( "TestService", "Network Type: " + 
niCommon.getTypeName() );
                Log.i( "TestService", "Network Type: " + 
niCommon.getDetailedState().toString() );
            }
        }
    }
}

And I believe you need this in your manifest:

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

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

See how that works out for you as a test.

Steven
Studio LFP
http://www.studio-lfp.com


On Monday, October 24, 2011 1:01:56 AM UTC-5, sourabh wrote:
>
> I have a TextView, what I want is whenever my Network comes 
> online/offline.It should get reflected to TextView.
> How Can I do this.
>  
> Please suggest.
> Thanks,
> Sourabh
>

-- 
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to