I have collected following information while going through various blogs, android web guide and during my own coding experience. So my due regards to the authors. These are really tiny and important pieces of information. I'll update the list as I increase my collection-
- Is your Intent Already Handled by other Activity? PackageManager- checks whether there is any activity which listens to an Intent.
When you call startActivity(), ActivityNotFoundException is thrown if there is no Activity which handles a specific Intent. So imagine, you can prompt user to download a missing app containing the required Activity.
- Portrait to Landscape change-
onRetainNonConfigurationInstance() and get the stored object- getLastNonConfigurationInstance() Don’t store View, Drawable, Adapter etc. UI classes into the store, which might cause Leak Window. Rather store raw data e.g. collection of bitmap, text etc.
Android UI-ToolKit (Views, Drawables etc.) is not thread safe. So it’s not recommended to access view classes from a
. We can use AsynchTask – which does heavy operation (not updating UI classes) on a Worker thread and UI update on UI Thread. Scenario- “Download an image from HTTP Server and create an ImageView”. In doInBackground() download the image and create the ImageView in onPostExecute(). IMPORTANT:Make sure that you access the Android UI toolkit only in the UI thread
Synchronization lock for static method or static block is the lock of class object which is different than the lock of object instances i.e. this. This seems out of track but this is a generic knowledge and important for object synchronization.
"A Handler is not a message loop, it is a recipient for messages. The messages sent to it are dispatched by the message loop of the thread that created the handler"- is a very important phrase. By default it uses Main Thread i.e. UI Thread’s message queue. You should use a different threads Message queue and shouldn’t share the one which is present in UI Thread-
HandlerThread handlerThread = new HandlerThread("Easy_Widget_Task");
Handler handler = new Handler(handlerThread.getLooper(), this);
Avoid Leak Window-
a good article on this
Getting HROF Dump from Android DDMS and ADB
Note the PID. Send SIGUSR1 signal using adb shell command, kill -10