android tips and tutorials

How to enable a physical Android device (phone or tablet) for development and debugging alvin June 14, 2017 - 7:28pm

To enable a physical Android hardware device (phone or tablet) for developing and debugging your apps with Android Studio, follow these steps.

1) Enable “Developer Options”

The first thing you have to do with a new Android device is to enable the developer options in the Settings app. To do this:

How to turn off the Android haptic feedback vibration setting alvin March 12, 2017 - 5:30pm

If you want to turn off the Android haptic feedback vibration setting on Android 7, I just found that you have to follow these steps:

Settings > Sound > Other sounds > Vibrate on tap

It feels odd that the setting is buried under the “Sound” setting, but there it is.

Instructions for filing an Android bug report alvin March 10, 2017 - 11:25am

As a quick note (circa March 10, 2017 and Android 7), I filed an Android bug report recently, and when I did, one of the Android developers asked if I would file an Android bug report. To do so, they gave me these instructions:

“After reproducing the issue, navigate to developer settings, ensure ‘USB debugging’ is enabled, then enable ‘Bug report shortcut’. To take bug report, hold the power button and select the ‘Take bug report’ option. Note: Please upload the files to google drive and share the folder to, then share the link here.”

I thought that was interesting, I had never seen the “Bug report shortcut” approach before.

How to use the Android 7 split screen feature (tutorial) alvin March 9, 2017 - 11:03am
Table of Contents1 - How to use Android’s split-screen feature2 - Rotating your device3 - Android 7 split-screen divider control4 - The split-screen “Recent Apps” icon5 - The “App doesn’t support split screen” message6 - Summary: Android 7 split-screens

Android 7 comes with a cool new “split screen” feature where you can look at two apps running at the same time. This little pictorial/tutorial shows how to use this split-screen feature.

An Android blog post about optimizing memory-related issues alvin March 1, 2017 - 5:33pm

The Android Developer’s Blog has a good article on how to optimize various memory attributes of Android applications, titled, Getting Santa Tracker Into Shape. A nice thing about their project is that they make their source code available on Github.

An Android ActionBar + ListFragment example alvin February 23, 2017 - 10:45am

The source code below corresponds to an article I wrote titled, Android ActionBar example: How to create an options menu item.

Android advertising revenue exceeds iOS ad revenue alvin February 22, 2017 - 5:25pm

Per The Register, “Advertising revenue flowing back to app developers from Android apps has exceeded the amount returned to developers by Apple for the first time.”

How to print an array in Android Log output (Logcat) alvin February 7, 2017 - 7:55pm

If you need to dump the contents of an array to the Android Log (Logcat) output, I can confirm that this approach works, at least with simple arrays of integers and strings that know how to print themselves:

Log.i("MyAndroidClass", Arrays.toString(arr));

If you’re trying to print more complicated arrays of custom objects you’ll probably need to implement good toString methods on those objects, and then this technique should work.

A note about functional programming in Android alvin January 29, 2017 - 9:18am

I spent some time last week working on an Android application, and with my newfound knowledge of functional programming (FP), I was trying to apply FP principles to my Android Activities and Fragments.

Android isn’t really meant for FP, but one thing I found that I could do is to move a lot of my business logic out of the Activities and Fragments and into separate classes, where I could often implement methods as static functions. The advantage of this is that it forces you to consciously pass variables in and out of those static functions, rather than mutating them as instance variables (think “global” variables) in your Activities and Fragments (which is a common way to handle them).

I don’t have a specific example I can share today, but when I can I’ll update this post to show specifically what I mean. In the meantime, if you try to move some of your logic out of your Activities and Fragments, I think you’ll see what I mean.

Next version of my Android football game alvin January 28, 2017 - 5:41pm

This image shows a very early (ugly) prototype of the next version of my Android football game. The orange boxes on the bottom-left let you choose the formation, then the “run,” “pass,” and “other” icons stand for tabs that let you choose different plays. I may put the formations inside a tab as well ... that would be more consistent, and it will be something I’ll need to do as the game grows.

A major new feature in the game is that you can can create your own custom teams, with each player on the team having a collection of ratings. For instance, a running back will have rating categories of a) running, b) blocking, and c) pass-catching abilities. Therefore, the running plays will let you choose to run left or right, and passing plays will let you choose the intended receiver.

I’ll write more as time goes on, but this ugly little prototype is one of the first steps in the redesign/upgrade.