Category Archives: Java

Xamarin – Migration Journey (Part 3 – Legacy code integration)

This is actually the hard part, and the failure at this point actually prevents us from moving towards with Xamarin.

We have been developing with native iOS and Android for 6 years, with lots of legacy code and libraries. Our libraries in both iOS and Android can have up to 20-30,000 lines of code. To migrate all of them to Xamarin would be a huge deal. The only solution is to connect Xamarin with those libraries.

We have libraries in 3 languages: Objective-C, Swift and Java. The first trouble came up when Xamarin could not connect with Swift framework. In our experiment, we took the risk and port 1 of our library into Objective-C. The Swift framework issue should have signaled us that something was not going right.

Anyways, we move forward with our intention to write a real project, working on both iOS and Android, and connect with 5 of our libraries and use 3 cocoapods frameworks/libraries.

For the libraries we wrote, there was not much problem, except the Swift issue mentioned above. However, with cocoapods, when people write code in all shapes and forms, the API definition kept having weird issues that we could not comprehend. We spent 3-4 man days on this, and still wasn’t sure that if the code would work or not.

We will discuss more about what binding issues we have with Xamarin that forced us to change the direction: to try to at least make a workable app with missing elements and libraries working in Xamarin

 

Controls Android New Site

ControlsAndroid.com

ControlsAndroid.com

I am so excited to announce my new site: ControlsAndroid.com where I show my collection of all android controls that I find on the internet. We are still updating it everyday, so please spend time visiting the website, download and use the controls for your cool app. Leave my any comments or suggestions on how to improve the site much better for the community.

For a better Android Interface

Improve your Android emulator performance

Want to supercharge your Android emulator in Eclipse/IntelliJ, use the following, excellent tip from Stackoverflow

IMPORTANT NOTE : Please first refer to Intel list about VT to make sure your CPU support Intel VT.

HAXM Speeds Up the Slow Android Emulator

HAXM stands for - “Intel Hardware Accelerated Execution Manager”

Currently it supports only Intel® VT [Intel Virtualization Technology]

The Android emulator is based on QEMU; The interface between QEMU and the HAXM driver on the host system is designed to be vendor-agnostic.

HAXM

Steps for Configuring Your Android Development Environment for HAXM

  1. Update Eclipse: Make sure your Eclipse installation and the ADT plug-in are fully up to date.
  2. Update your Android Tools: After each Eclipse plug-in update, it is important to update your Android SDK Tools. To do this, launch the Android SDK Manager and update all the Android SDK components. To take advantage of HAXM, you must be on at least release version 17.

enter image description here

  • Download the x86 Atom System Images and the Intel Hardware Accelerated Execution Manager Driver: Follow the image below:

enter image description here

  • Install the HAXM Driver by running “IntelHaxm.exe”.
    It will be located in one of following locations:

    • C:\Program Files\Android\android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager
    • C:\Users\<user>\adt-bundle-windows-x86_64\sdk\extras\intel\Hardware_Accelerated_Execution_Manager

    If the installer fails with message that Intel VT must be turned on, you need to enable this in BIOS. See description for how to do this here.

Install .exe or .dmg

  • Create a New x86 AVD: Follow the image below:

Create AVD

  • Or as for new SDK, enter image description here

Windows Phone Potential?

I normally hear from Windows developer to say that their Windows market share is much bigger than the total of iOS and Android together. And the sales of Windows 8 has bypassed all the sales of iOS and Android from the beginning to now.

Windows Phone 8

Windows Phone 8

It is quite unfair to compare the whole Windows 8 with iOS or Android. And if we do take that demand into PCs and laptops, then why the hell we do not compare the supply side? It is very clear that if Windows 8 could be a shared platform between PCs, tablets and phones, then all the old software, all the old games would have beome compatible to the Windows 8 system in the short amount of time. And many apps for tablets and phones would be quite different than the ones in PC. No, I don’t mean technology, I am talking about the business model, the purpose of the software.

I don’t mean that iOS and Android is a better market than Windows Phone for indie business. These markets have become very competitive and continue being so. You either have to figure out a market niche or be very lucky.

iPhone v.s Android

The smartphone game is over. The tablet game will be finished soon, within 2 years.

iPhone versus Android

iPhone versus Android

 

 

Android wins, iPhone loses. 75% v.s 15%, soon will become 85% v.s 5%. But that doesn’t matter much for Apple. Apple is a brand for high-end products. They don’t aim to gain all market share. To gain market share, Apple has to attack more of the low-end market, which means they have to lower their price. However, matching other supplier’s price may be harmful for Apple’s brand, although they may achieve it by more efficient supply chain and factories.  To become a high-end brand, Apple spends a significant amount of money on their brand and will not scarify it for the market share.

But in this ecosystem war, the bigger ecosystem leads to a win by monopoly. When 75, 80 or 85% of the market is using Android, app developers will flock to there, and make the ecosystem become much more valuable for customer. To continue earning a lot of money, Apple has to continue what it has done best under Steve Jobs’s empire. New product, new market, new value, or new software that people are willing to purchase with high-price.

What will be the next Apple’s product? Probably Apple TV, I am not even sure about that.

And the important questions for most of us, as app developers, what should we do? Should we all move to Android yet, should we change our strategy of iOS first, Android second? Or should we start discussing about Mobile Web App?

I am writing more on the Mobile Web App v.s Mobile Native App in the next post, catch it soon.

Robocode New Beta Release

Robocode Logo

Robocode Logo

 

Robocode has released a beta version for 1.7.3.0, I am happy to contribute 1 feature and 1 bug fix in this release. Please download, test it and tell us any bugs you found

 

 

 

Reference:

Robocode in SourceForge

Anonymous class Java

Some days ago, when answering a question on stackoverflow , I just recognized that I didn’t understand much about anonymous class in Java. Maybe I am not the only one, so I post it here. I think this should be in some book already, but by my bad, I didn’t read it well.

Ok, here is a simple question on stackoverflow:

 public static void main(String[] args) {
        System.out.println(
          new myClass() {
             public String toString() {
               return "myInterfacetoString";
             }
           });

        System.out.println(
          new myClass() {
              public String myFunction() {
                return "myInterfacemyFunction";
                }
          });
    }
and the user asked why the output is:
               myInterfacetoString
               primitivedemo.Main$2@9304b1

It is extremely easy, right? Because you override the method toString() of the Object class. But then, the questioner asked more: how about change from new myClass() –> new myInterface() with some interface myInterface already declared, what would happen?

My first thought is that the class name of the anonymous class is not necessary and having no relationship with the real class, interface sharing the same name

But I just remembered about some of my snippet code before with

      new Runnable(){
       @override
       public void run() {}
      }

will behave well like a runnable object

So, what is a correct way of anonymous class. After asking Google, I found a good link about it:

http://www.developer.com/java/other/article.php/3300881/The-Essence-of-OOP-using-Java-Anonymous-Classes.htm

There are 2 main important points:

new className(optional argument list){classBody}

This expression instantiates a new object from an unnamed and previously undefined class, which automatically extends the class named className, and which cannot explicitly implement any interfaces. The body of the new class is given by classBody.

The result of executing this expression is that a new class that extends className is defined, a new object of the new class is instantiated, and the expression is replaced by a reference to the new object.

new interfaceName(){classBody}

This expression instantiates a new object from an unnamed and previously undefined class, which automatically implements the interface named interfaceName, and automatically extends the class named Object. The class can explicitly implement one, and only one interface, and cannot extend any class other than Object. Once again, the body of the new class is given by classBody.