Android PubNub Integration Tutorial (Setup and Basic Publish/Subscribe Usage)

PubNub is a lovely SaaS platform that helps us build realtime applications very fast without coding our own backend infrastructure. It has 60+ SDKs and can be used with JavaScript, Ruby, PHP, iOS, Android, Python, etc. In this specific article, we’ll deal with the Android SDK only. So in my Android application I had to code a small chat piece where multiple people could chat in groups (similar to WhatsApp groups). The idea of this article is to quickly show you how to install the PubNub Android SDK in your app and get started.

Continue reading “Android PubNub Integration Tutorial (Setup and Basic Publish/Subscribe Usage)”

How to Check/Detect Whether Current Thread is UI/Main Thread or Not in Android

Checking whether the current thread is the UI/Main thread or some other background thread is very easy. Here’s the code for it:

Continue reading “How to Check/Detect Whether Current Thread is UI/Main Thread or Not in Android”

Android Using a Scrollable ViewGroup Like ScrollView, ListView or GridView In a ScrollView With requestDisallowInterceptTouchEvent()

There are times when you want to have a scrollable ViewGroup like a ViewPager or a ListView or a GridView inside another scrollable ViewGroup like a ScrollView. You could have various combinations like a ViewPager in a ListView, a ViewPager and a ListView inside a ScrollView (this is what I had to do in my Android app), etc. in your application.

Continue reading “Android Using a Scrollable ViewGroup Like ScrollView, ListView or GridView In a ScrollView With requestDisallowInterceptTouchEvent()”

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”

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”