Monday, October 7, 2013

Programming things to remember 2013 Sept


- Attach a BroadcastReceiver to listen for DownloadManager.ACTION_DOWNLOAD_COMPLETE.
- Finish the (only) Activity. At this point the app process will still run
- Disable wifi
Result: the app process will be killed, no broadcast received when the download is paused, nor when the framework continues and finishes the download.


Broadcast will be received even if the app is in the background, if BroadcastReceiver was registered. It is just a good practice to unregister it if not needed (because it may consume resource in vain). So generally you should unregister onPause() if you registered it onResume(). Test code.

If you register the broadcast receiver with the activity's context, it will receive broadcasts as long as the activity is alive. However, you can register the receiver with the applicatino context, and it will still receive broadcasts even if the activity isn't alive. cited from here

Public field (member variable) Matcher

I wrote one. Code here

NineOldAndroid animation

When you use NineOldAndroid for property animation, it will still Value-animate under the hood. Meaning if a View has button and you rotate it by 90 degrees around the y axis (or animating the visibility to gone). The button will be still clickable.

No comments: