Android Navigation: Up vs Back

Android has two distinct navigation guidelines as opposed to iOS. Getting them right is nuanced.

Android uncaught exception handler and ANR

While trying to install a custom exception handler to catch uncaught exceptions (crashes), I ended up writing

What's the best alternative to Google Play Music and Google Podcasts...

Google Play Music was great. Apart from one missing feature about the inability to upload music from the phone to the Google Play Music library, I had no other complaints. Then it was forcefully shut down.

Android: Catching NDK crashes

On Android catching Java exceptions is easy via UncaughtExceptionHandler. Catching NDK crashes is a bit more convoluted. Since the native stack is probably corrupted, you want the crash handler to run on a separate process. Also, since the system might be in an unstable shape, don’t send the crash report to your web server or do anything fancy. Just write the crash report to a file, and on the next restart of the app, send to your web server and delete it from the disk. I ended up using jndcrash package for this.

Dealing with phone numbers in contact book

If you are building an app that uses the user’s contact book then their certain gotchas to avoid. Telephone country codes are prefix-free If a country has a country code “+91”, then no other country will get a country code like “+912” or “+913”. This scheme ensures that numbers are inherently unambiguous. Telephone numbers can have multiple representations Since most people don’t dial internationally, telecom systems implicitly assume a domestic call....

Troubleshooting Android Emulator: "Emulator: Process finished with exit code 1"

Emulator: Process finished with exit code 1 You opened AVD Manager in Android Studio and tried to start an AVD, you got “Emulator: Process finished with exit code 1”. Following are the steps to debug this Find out the name of the emulator. Click the down arrow 🔽 which is to the right of play arrow ▶️, to find out the name of the AVD. Let’s say the name is “Nexus_5X_API_28_x86”....

Android: Using "Die with me" app without killing the phone's battery

Die with me is a chat app which can be used only when the phone’s battery is below 5%. Here is a fun way to use the app without draining your phone’s battery. Connect the phone via ADB or start Android emulator and fake the battery level to 4%. Default 1 2 sudo pip3 install adb-enhanced adbe battery level 4 # Set battery level to 4% And now, you can use the app....

Circle CI vs Travis CI

Update: As of Mar 2022, I recommend everyone to use GitHub Actions I maintain a somewhat popular Android developer tool ( adb-enhanced). The tool is written in Python, supporting both Python 2 and 3. Testing the tool requires both Python runtime as well a running Android emulator. I, initially, used Travis CI for setting up continuous testing of this tool. Later, I felt that Travis CI was too slow and when I came across Circle CI, I decided to give it a try. As of now, both Travis and Circle CI are used for testing. Here is what I learned from my experience.

Android Security: Don't leave WebView debugging enabled in production

WebView debugging can be enabled via “WebView.setWebContentsDebuggingEnabled(true)”. Leaving WebView debugging enabled in production Android apps is a bad idea. Anyone who gets hold of the unlocked phone can access the app’s data forever.

Android: Fragment related pitfalls and how to avoid them

Don’t use platform fragments ( android.app.Fragment), they have been deprecated and can trigger version-specific bugs. Use the support library fragments ( android.support.v4.app.Fragment) instead. A Fragment is created explicitly via your code or recreated implicitly by the FragmentManager. The FragmentManager can only recreate a Fragment if it’s a public non-anonymous class. To test for this, rotate your screen while the Fragment is visible. FragmentTransaction#commit can fail if the activity has been destroyed....