Saturday, October 24, 2015

Android Installs in 2015

Here are my GLOBAL Android Installs (40,000 sample)


Android 2.3 - 11% - unchanging to slowly decreasing
Android 3.2 - 2% - unchanging to slowly decreasing
Android 4.0 - 13% - unchanging to slowly decreasing
Android 4.1 - 14% - unchanging to slowly decreasing
Android 4.2 - 15%  - unchanging
Android 4.3 - 3% - unchanging to slowly decreasing
Android 4.4 - 26% - increasing
Android 5.0 - 5% - sharply increasing in summer 2015, leveling
Android 5.1 - 3% - sharply increasing since October 2015


Android 4.4 - 50%
Android 4.2 - 20%
Android 4.1 - 8%
Android 5.x - 13%

Wednesday, July 29, 2015

git command line on Mac

I had to start using a new Mac, so it was good time to review my toolset.

$ git --version
git version 2.3.2 (Apple Git-55)
$ which git/usr/local/bin/git

After the brew install

brew install git
$ git --version
git version 2.2.0
$ which git

it seems that the version of Brew is older, so I advise staying with Apple (Developer's Tools).

Thursday, June 25, 2015

Java: Unsupported major.minor version 51.0

When you get an error:

Unsupported major.minor version X

This means that you are trying to compile your Java program with version lower that the code is written for; for example you develop with Java 1.7, deploy on the server where they have Java 1.6:

Unsupported major.minor version 51.0

The fix is:

  • to change your code to use lower Java, which is sometimes impossible because of 3rd party library that you are using
  • upgrade the other computer to modern Java, which is sometimes impossible because of a brick-head gatekeeper
  • vent on the blog and start cutting out the code 

Java versions:
  • J2SE 8 = 52
  • J2SE 7 = 51 
  • J2SE 6.0 = 50 
  • J2SE 5.0 = 49 
  • JDK 1.4 = 48 
  • JDK 1.3 = 47 
  • JDK 1.2 = 46 
  • JDK 1.1 = 45

Monday, June 22, 2015

RoboGuice - Android development made simple and fun

"Simple and Fun!" Now, they make quite a promise!

read up:

Maven repo:


OK, so most of all RoboGuice is about DEPENDENCY INJECTION


TextView label;

@InjectResource(R.string.app_name) // strings, drawables
String applicationName;

@Inject // system service
LayoutInflater layoutInflater;

LocationManager locationManager;

@Inject // POJO
Book book;

Creating Activities

public class FightForcesOfEvilActivity extends RoboActivity {

TextView expletiveText;

Creating Android Modules

public class MyModule extends AbstractModule {
protected void configure() { }


public static class AsyncPunch extends RoboAsyncTask {

// Astroboy is a @Singleton public class Astroboy {
@Inject Astroboy astroboy;

// new instance of java.util.Random, since we haven't specified any binding instructions
@Inject Random random;

SHH key

$ git clone
Cloning into 'roboguice'...

Permission denied (publickey).

$ ls -al ~/.ssh
total 120
-rw-------   1 uki  staff   1675 Oct 31  2012 id_rsa


$ pbcopy < ~/.ssh/ 

PASTE your SSH key exactly as copied (i.e. in GitHub settings)

$ git clone roboguice
Cloning into 'roboguice'...
remote: Counting objects: 18463, done.

Receiving objects:  15%

Tuesday, June 16, 2015

MacBook Pro (late 2011) graphics crashing

With the update to Yosemite (maybe unrelated) my Mac started to crash, at first it was rare, but right now it is consistent, the common situations when it is crashing:

  • connecting external monitor via HDMI
  • connecting external monitor via VGA
  • screen sharing using JoinMe 
  • bad days in general
The MacBook Pro (starting with early 2011) have 2 GPU (graphic cards), one integrated, low power, and one additional (discrete) that is used for high power situations.

I installed the utility called gfxCardStatus that allows me to switch between integrated and discrete graphic cards.

From their website:

gfxCardStatus v2.3 and above actively prevents you from switching to Integrated Only mode when any apps are in the Dependencies list (or if you have an external display plugged in). This is because if you were to do this, your discrete GPU would actually stay powered on, even though you've switched to the integrated GPU.

So I guess no more external display for me until Apple fixes the problem, or I but new MacBook Pro (hopefully with touch screen this time).

Reseting System Management Controller (SMC)

Thursday, June 11, 2015

Java: Closable

When working with multiple resources that need to be closed after we are done using, I particularly like the approach of using Closable Interface:

try {
    // open input streams and use them  
catch (IOException e) {
finally {

private void attemptClose(Closeable object) {
    if (object != null) {
        try {
        catch (IOException ignore) {

Apple Photos opening every time phone USB is connected

I work developing Android so I plug and unplug different devices all day long. Apple Mac Photos app is opening every time phone USB is connected, which is frustrating and sometimes out of place at work.

To turn off that behavior next time the Photos app opens UNSELECT THIS CHECKBOX:

"Open Photos for this device"

Android: TextView in ScrollView continous scrolling

Sometimes when continuously outputting text to TextView, you would like it to scroll down:

textView.addTextChangedListener(new TextWatcher() {
    @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    @Override public void onTextChanged(CharSequence s, int start, int before, int count) {
        // scroll down whenever log text updated to display latest info on the screen        
        Runnable() {
            @Override public void run() {

    @Override public void afterTextChanged(Editable s) {

Monday, June 8, 2015

Android: AsyncTask delegate

Let say we have an Activity that wants to receive a messages from AsyncTask.

We create an Interface AsyncResponse

public interface AsyncResponse {
   void publishLog(String logContent);

We create our AsyncTask:

public class FileReaderTask 
 extends AsyncTask < Void, Void, List < AbstractX > > {
// delegate should be set in the Activity   
public AsyncResponse delegate = null;
String xyz = "";

// ...

@Overrideprotected void onPreExecute() {

@Overrideprotected void onPostExecute(List x) {

Now we can tie together the AsyncTask and Activity:

public class FileReaderActivity extends Activity implements AsyncResponse {

   private static final String TAG = FileReaderActivity.class.getCanonicalName();
   FileReaderTask asyncTask = new FileReaderTask();

   private TextView logText;

   /**    * Called when the activity is first created.    */  

 @Override   public void onCreate(Bundle savedInstanceState) {
      logText = (TextView) findViewById(;

      // tell Async Task that this Activity will listen      

asyncTask.delegate = this;

   /**    * This method will receive log from Async Task.    * @param logContent    */   

@Override   public void publishLog(String logContent) {