android tips and tutorials
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.
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 email@example.com, then share the link here.”
I thought that was interesting, I had never seen the “Bug report shortcut” approach before.
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.
The source code below corresponds to an article I wrote titled, Android ActionBar example: How to create an options menu item.
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.”
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:
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.
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.
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.
If you want to hide the Android ActionBar on an Activity, it looks like there are at least two approaches.
First, add the
android:theme="@android:style/Theme.NoTitleBar" entry to the activity’s definition in AndroidManifest.xml:
<activity android:name=".PlayAGameActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > </activity>
A second approach is to add this code in the Activity (or Fragment)