14 June 2016
Support fake Android TV devices
Android TV is included in some modern Smart TVs, and there are also external set-top-boxes to get Android TV for any TV with HDMI input.
However, there are also some set-top-boxes which almost, but not quite, support Android TV.
With not so much extra effort, it is possible to make an Android app supporting those fake Android TV devices as well as the real ones.
In addition to the guidelines from Google for building Android TV apps, do this to support the fake TV Android TV devices as well:
16 May 2015
Custom Preference for Android
I need a setting with a numeric value in my Android app. There is no obvious fit among the standard Preferences in Android, so I decided to implement my own Preference subclass.
This was a bit more involved than what I hoped for. I ended up with this. An improvement would be to be able to configure min and max values through XML attributes.
public class NumericPreference extends DialogPreference { private static final int DEFAULT_VALUE = 0; private NumberPicker mWidget; private int value = DEFAULT_VALUE; public NumericPreference(Context context, AttributeSet attrs) { super(context, attrs); setDialogLayoutResource(R.
4 March 2014
Don’t use PipedOutputStream on Android
I was using java.io.PipedOutputStream in an Android app. The app performed horribly bad. After doing some profiling, it turned out that the call to PipedOutputStream.write(byte[]) that was really slow. After digging into the Android source code, I discovered that PipedOutputStream.write(byte[]) was not implemented, it just delegated to the default implementation in OutputStream which iterate through the array and call PipedOutputStream.write(byte) for each byte.
Since PipedOutputStream.write(byte) does some synchronization and Object.notifyAll() each time, it is really slow to do this 1000 times when you write a block of 1 KB data.
1 January 2013
Using AAC music files in Android
If you have a file with .aac extension, it is AAC encoded audio in an ADTS container. If you want to play such file on an Android device, you have problems. Android 2.x does not support this file format at all, and not even the latest version of Android supports reading metadata tags from it.
The solution is to repackage the audio in an MPEG-4 container to a file with .