Last day here. (at 街旁台灣office)
via Tumblr http://cyberrob.tumblr.com/post/51793096468
Last day here. (at 街旁台灣office)
From Evernote: |
Managing Network Usage | Android DevelopersClipped from: http://developer.android.com/training/basics/network-ops/managing.html |
Setting up a BroadcastReceiver that gets called unnecessarily can be a drain on system resources. The sample application registers the BroadcastReceiver
NetworkReceiver
in onCreate()
, and it unregisters it in onDestroy()
. This is more lightweight than declaring a <receiver>
in the manifest. When you declare a <receiver>
in the manifest, it can wake up your app at any time, even if you haven't run it for weeks. By registering and unregistering NetworkReceiver
within the main activity, you ensure that the app won't be woken up after the user leaves the app. If you do declare a <receiver>
in the manifest and you know exactly where you need it, you can use setComponentEnabledSetting()
to enable and disable it as appropriate.