mudit wrote:
> Hi..
>
> i am need to receive broadcast for network actions like network
> connected, disconnected etc. I am using a broadcast receiver for the
> purpose.Can any please tell me which intent action i need to capture
> for network events, right now as per my search on internet i am using
> android.net.ConnectivityManager.CONNECTIVITY_ACTION.
>
> here is my broadcast receiver class--
>
> import android.content.BroadcastReceiver;
> import android.content.Context;
> import android.content.Intent;
>
> public class NetworkStateReceiver extends BroadcastReceiver {
>
> @Override
> public void onReceive(Context context, Intent intent) {
> // TODO Auto-generated method stub
>
>
> if (intent.getAction().equals(
> android.net.ConnectivityManager.CONNECTIVITY_ACTION)) {
>
> // do something..
>
> }
> }
>
> }
>
> and i have also added permission for accessing network state.
>
> <uses-permission
> android:name="android.permission.ACCESS_NETWORK_STATE">
> </uses-permission>
>
> here is how i have declared this class in manifest file --
>
> <receiver class=".NetworkStateReceiver"
> android:name=".NetworkStateReceiver">
> <intent-filter>
> <action
> android:name="android.net.ConnectivityManager.CONNECTIVITY_ACTION" />
> </intent-filter>
> </receiver>
>
> Please suggest me right intent action if i am wrong OR if there is any
> other way to catch network events.
You can try registering the BroadcastReceiver as part of some other
component (Activity, Service) via registerReceiver(). Not all broadcast
Intents work with manifest-registered receivers.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
_Android Programming Tutorials_ Version 1.0 In Print!
--
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