Wednesday, August 31, 2011

JSON - Accessing object with hypen/dash

If you encounter json object that have - (hypen/dash) in the key, you will get a reference error if you access the object with dot manner. For example

{"cam-id":"1"}

Assuming the above object is call json_results, you will get an reference error if you

json_results.cam-id

You have to access the value by

json_results["cam-id"]

JQuery Mobile - Transition Flicker

Some may realize that when you transit from 1 page to the other, there is a flicker during the transition. You may try the following to prevent the flicker

.ui-page {
-webkit-backface-visibility: hidden;
}

Saturday, August 13, 2011

Android - Read Multimedia File from Assets folder

To read a multimedia file from assets folder via MediaPlayer, you could use the following code

AssetManager am = getAssets();
//Imagine you have a folder assets/mp4
AssetFileDescriptor afd = am.openFd("mp4/test.mp4")
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
//I am assuming that you have knowledge in getting a surfaceHolder from SurfaceView
mediaPlayer.setDisplay(surfaceHolder);
mediaPlayer.prepare();
mediaPlayer.start();

Wednesday, August 3, 2011

Android - Debug with hardware device in Eclipse

If you want to debug your Android application with Eclipse on real device, this post may help you.

1. Following the http://developer.android.com/guide/developing/device.html information to setup your phone

2. Connect your mobile device to PC via USB

3. Check if your device is attached properly with the following command


4. Open your Eclipse, Run -> Debug configuration

5. Make sure Manual is selected for Deployment Target Selection Mode and click save


6. If you perform normal debugging in Eclipse, the following should appear. Click on the running device and ok.


7. Debugging should start and if you switch to DDMS, you should see debug logging at the LogCat while you play around with the phone





Hadoop - How to setup a Hadoop Cluster

Below is a step-by-step guide which I had used to setup a Hadoop Cluster Scenario 3 VMs involved: 1) NameNode, ResourceManager - Host...