Reputation: 11
folks,
I would like build an app using android which relies on networking. As we could not know when network connection will be lost, I build an service to monitor the status, and I wanted to kill certain activity when the network is not within access.
Thus, my question is how I can find reference for that activity, I assume it already started, to destory it?
Thanks!
Upvotes: 0
Views: 262
Reputation: 64399
You should use an INTENT
, and your activity can use an intent-filter. You would use an "Explicit intent" for this.
This is basically a way to message activities that you want to do something. So you let the activity destroy itself (and maybe alert the user, do some cleanup etc.)
See http://developer.android.com/guide/topics/intents/intents-filters.html
Upvotes: 1
Reputation: 12375
You can implement a BaseClass for all your activities and use the ConnectivityManager to listen to network status changes and finish your activity based on the condition.
Also before you do kill the activity do notify the user why the activity was killed.
Upvotes: 0