Understanding Android Input Touch Events System Framework (dispatchTouchEvent, onInterceptTouchEvent, onTouchEvent, OnTouchListener.onTouch)

On my journey of learning Android Development, I’ve realised that it is really important to understand the input handling especially how the entire touch events framework work. Wrapping your head around the entire propagation of touch events (including the gesture) is imperative else while coding you’ll find yourself stumped by the behaviour of different ViewGroups (or Views) when attaching touch listeners to them with the hope that your code works as expected when they actually won’t. It gets even tricker when you have ViewGroups like ViewPager or ListView (both scrollable) inside other scrollable ViewGroups like ScrollView.

Continue reading “Understanding Android Input Touch Events System Framework (dispatchTouchEvent, onInterceptTouchEvent, onTouchEvent, OnTouchListener.onTouch)”

Android Emulator HierarchyViewer “Unable to get view server protocol version from device” Error

If you’re running your application in the Android Emulator and suddenly the Hierarchy Viewer stops loading up the View Hierarchy in the standalone tool or in Android Device Monitor then chances are high that ADB server needs to be restarted in order to fix it.

Continue reading “Android Emulator HierarchyViewer “Unable to get view server protocol version from device” Error”

Android Add Views or View Groups Below a ListView or GridView

You might be thinking showing up a View like TextView, ImageView, EditText, Button, etc. or a ViewGroup (wrapping other Views) like RelativeLayout or LinearLayout below a ListView/GridView must be easy. It’s not. Not in Android atleast.

Continue reading “Android Add Views or View Groups Below a ListView or GridView”

Android Saving Files on Internal and External Storage

Android allows us to store files in its file system which is quite similar to any other Linux filesystem that you must have experience with. Using the java.io file input/output APIs we can start reading and writing files to the Android filesystem. This is super useful when you want a store files (but not relational data or some sort of key/value cache pairs) on the device. Files like audio, video, images, documents, etc. all makes sense to store in the file system when required.

Continue reading “Android Saving Files on Internal and External Storage”

Android Application Data Storage With SharedPreferences

Android has a concept of shared preferences using which application preferences data can be stored persistently. That means the data or state won’t be lost until the application is uninstalled. The preferences data can be stored as key/value pairs and are available across all the Activities of the given application or can also be restricted to a particular Activity.

Continue reading “Android Application Data Storage With SharedPreferences”

Get Application APK File from Android Device To Your Computer

In this quick tip, we’ll see how to use the excellent Android Debug Bridge (adb) tool on the command line to list all the installed packages on our android device (non-rooted in my case) and then extract one of their APK files to our computer.

Continue reading “Get Application APK File from Android Device To Your Computer”

Execute ADB Commands To Query a Particular Android Device/Emulator

When using the versatile Android Debug Bridge (adb) tool to issue commands, if there’s only one device or emulator attached then that’s fine as the commands will be executed on exactly that. But if there’s more than one instance then we’ll get an error on the terminal saying error: more than one device and emulator.

Continue reading “Execute ADB Commands To Query a Particular Android Device/Emulator”