Pavan K
Pavan K

Reputation: 4693

How can I get notified if there is any network Activity?

If there is any network activity on the phone could I register to some intent filter and get notified of the events?

The arrows on top in the notification bar (both for wifi and hsdpa) move, So I am guessing there is some way to get notified.

Upvotes: 2

Views: 122

Answers (1)

nandeesh
nandeesh

Reputation: 24820

Use the following code to register for listener

((TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE))
 .listen(mPhoneStateListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
                      | PhoneStateListener.LISTEN_DATA_ACTIVITY);

in Phonestatelistener.OnDataActivity you will recieve callback

Upvotes: 1

Related Questions