Posts Tagged ‘android’

Jelly Bean source code prepared to release within today

Seem like Google has decided to release the JellyBean v4.1 earlier than expected in mid-July.

Just wait and be ready to get new chewy source code:

Categories: Of Diary Tags: , , ,

Android SDK v4.1 – Jelly Bean released! Check it out


Yeah, it’s like Google has decided to release the SDK sooner than mid-July…anyway, only Nexus Q to test 😦

Android v4.1 SDK Update

Android v4.1 SDK Update

Categories: Of Diary Tags: , ,

Android XML Adventure – Parsing XML using XPath

December 24, 2011 4 comments

Article Series: Android XML Adventure

Author: Pete Houston (aka. `xjaphx`)


  1. What is the “Thing” called XML?
  2. Parsing XML Data w/ SAXParser
  3. Parsing XML Data w/ DOMParser
  4. Parsing XML Data w/ XMLPullParser
  5. Create & Write XML Data
  6. Compare: XML Parsers
  7. Parsing XML using XPath
  8. Parsing HTML using HtmlCleaner
  9. Parsing HTML using JSoup
  10. Sample Project 1: RSS Parser – using SAXParser
  11. Sample Project 1: RSS Parser – using DOM Parser
  12. Sample Project 1: RSS Parser – using XMLPullParser
  13. Sample Project 2: HTML Parser – using HtmlCleaner
  14. Sample Project 2: HTML Parser – using JSoup
  15. Finalization on the “Thing” called XML!


XPath is a syntax to query directly to the specified tag by name or id or using any pre-defined function to detect the nodes. It’s really useful when it’s coming to parse a lot of data in the form of an array.

You might want to study some about XPath first: W3Schools – XPath Tutorials

Specifically, we will apply XPath in Android platform, there’s a library also named XPath, pre-package in Android framework. Reference to Android XPath Library.

The usage of XPath is pretty much simple:

1. Create a `InputSource` object, from a `String`, from a `InputStream`, from `Resources`, from `Assets` ….

2. Create a `XPath` object

3. Define your XPath expression, which is a `String`.

4. Evaluate above expression from `InputSource` created at step 1.

5. Query data retrieved from evaluation.

That’s it. Here go for an example, I’ll have the following XML file, `data.xml`, and put into `/res/raw` folder.

<?xml version="1.0" encoding="UTF-8"?>
		<title>Using XPath to parse XML</title>
		<author>Pete Houston</author>
		<person id="1">
			<name>Pete Houston</name>

		<person id="2">
			<name>Nina Jones</name>

		<person id="3">
			<name>Yumin Hanazuki</name>

Following above 5 steps, including display data to UI.


import java.util.ArrayList;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;

import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Toast;

public class XPathStudyActivity extends ListActivity {
    // data
	ArrayList<String> mPeople = new ArrayList<String>();

    public void onCreate(Bundle savedInstanceState) {

        try {
        } catch(Exception ex) {
        	Toast.makeText(this, "Exception: " + ex.getMessage(), Toast.LENGTH_LONG).show();

        // pass adapter w/ data queried through XPath to ListView
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mPeople);

    private void parseData() throws Exception {
    	// create an InputSource object from /res/raw
    	InputSource inputSrc = new InputSource(getResources().openRawResource(;
    	// query XPath instance, this is the parser
    	XPath xpath = XPathFactory.newInstance().newXPath();
    	// specify the xpath expression
    	String expression = "//name";
    	// list of nodes queried
    	NodeList nodes = (NodeList)xpath.evaluate(expression, inputSrc, XPathConstants.NODESET);

    	Toast.makeText(this, "count: " + String.valueOf(nodes.getLength()),Toast.LENGTH_SHORT).show();
    	// if node found
    	if(nodes != null && nodes.getLength() > 0) {
    		int len = nodes.getLength();
    		for(int i = 0; i < len; ++i) {
    			// query value
    			Node node = nodes.item(i);

The above sample, I’ve tried to query all `name` XML tag from `data.xml` file and display on the list. Very simple usage w/ XPath library!

Have fun,
Pete Houston

Categories: Tutorials Tags: , , , , , ,

Retrieve all secrect codes from your Android devices

December 21, 2011 Leave a comment

In my previous post about list of Google Android Secret Codes, you may find them not working in every Android devices.

So the question is how to know the secrect codes in a specific Android phone?

After searching for a while, I’ve found the could-be answer, at the following link: XDA-Developers – Android’s secret codes

1. First, root your phone

2. Secondly, create this bash shell script, name it, maybe: “

echo -n &gt; apks.txt
echo -n &gt; output.txt
for x in `find . -name "*.apk"`
unzip -p $x | strings | grep -i "android.provider.Telephony.SECRET_CODE"
if [ $? -eq 0 ]; then
echo $x &gt;&gt; apks.txt
for x in `cat apks.txt`
mkdir "$x.folder"
mv $x $x.folder
for x in `cat apks.txt`
unzip -d $x.folder $x.folder/$x
for x in `cat apks.txt`
bin2xml $x.folder/AndroidManifest.xml &gt; $x.folder/AndroidManifest.decoded.xml
for x in `find . -name "AndroidManifest.decoded.xml"`
echo "$x:" &gt;&gt; output.txt
cat $x | grep -i host | sed 's/android:host=\"/*#*#/' | sed 's/\" \/&gt;/#*#*/' | sed 's/\t\t\t\t\t//' &gt;&gt; output.txt

3. Download this script:

and rename it to ““, then put somewhere in your Android phone $PATH.

4. Run the following commands:

chmod a+x
cat output.txt

5. Read your output and try it out!


Have fun!

Pete Houston

Categories: Tricks & Tips Tags: , , , ,

Google Android Phone Secret Codes

December 21, 2011 2 comments

A really interesting discovery, I’ve found on this page:

Justin.My – Google Android Phone Secret Codes


AskVG – Android Phone Secret Codes

These codes have been obtained by decoding various .apk files present in the phone firmware.


This code can be used to get some interesting information about your phone and battery. It shows following 4 menus on screen:

  • Phone information
  • Battery information
  • Battery history
  • Usage statistics


This code can be used for a factory data reset. It’ll remove following things:

  • Google account settings stored in your phone
  • System and application data and settings
  • Downloaded applications

It’ll NOT remove:

  • Current system software and bundled applications
  • SD card files e.g. photos, music files, etc.

PS: Once you give this code, you get a prompt screen asking you to click on “Reset phone” button. So you get a chance to cancel your operation.


Think before you give this code. This code is used for factory format. It’ll remove all files and settings including the internal memory storage. It’ll also reinstall the phone firmware.
PS: Once you give this code, there is no way to cancel the operation unless you remove the battery from the phone. So think twice before giving this code.


This code is used to get information about phone camera. It shows following 4 menus:

  • Update camera firmware in image (Don’t try this option)
  • Update camera firmware in SD card
  • Get camera firmware version
  • Get firmware update count

WARNING: Never use the first option otherwise your phone camera will stop working and you’ll need to take your phone to service center to reinstall camera firmware.


This one is my favorite one. This code can be used to change the “End Call / Power” button action in your phone. Be default, if you long press the button, it shows a screen asking you to select any option from Silent mode, Airplane mode and Power off.
You can change this action using this code. You can enable direct power off on this button so you don’t need to waste your time in selecting the option.


This code opens a File copy screen where you can backup your media files e.g. Images, Sound, Video and Voice memo.


This code can be used to enter into Service mode. You can run various tests and change settings in the service mode.
WLAN, GPS and Bluetooth Test Codes:
*#*#232339#*#* OR *#*#526#*#* OR *#*#528#*#* – WLAN test (Use “Menu” button to start various tests)
*#*#232338#*#* – Shows WiFi MAC address
*#*#1472365#*#* – GPS test
*#*#1575#*#* – Another GPS test
*#*#232331#*#* – Bluetooth test
*#*#232337#*# – Shows Bluetooth device address


This code can be used to launch GTalk Service Monitor.

Codes to get Firmware version information:

*#*#4986*2650468#*#* – PDA, Phone, H/W, RFCallDate
*#*#1234#*#* – PDA and Phone
*#*#1111#*#* – FTA SW Version
*#*#2222#*#* – FTA HW Version
*#*#44336#*#* – PDA, Phone, CSC, Build Time, Changelist number

Codes to launch various Factory Tests:
*#*#0283#*#* – Packet Loopback
*#*#0*#*#* – LCD test
*#*#0673#*#* OR *#*#0289#*#* – Melody test
*#*#0842#*#* – Device test (Vibration test and BackLight test)
*#*#2663#*#* – Touch screen version
*#*#2664#*#* – Touch screen test
*#*#0588#*#* – Proximity sensor test
*#*#3264#*#* – RAM version
NOTE: All above codes have been checked on Google Android phone Samsung Galaxy I7500 only but they should also work in other Google Android phones.

Also, some additional secret codes, found on Android-DLS – Secret Codes

  1. Display IMEI:
  2. Voice Dialer Logging Enabled
  3. Voice Dialer Logging Disabled
  4. Phone Setting
  5. FieldTest
  6. PUK Unlock (from emergency dial screen)
    **05*<PUK Code>*<enter a new pin>*<confirm the new pin>#

Some secret code specifically for Samsung Galaxy SII: *#0*#



Pete Houston

Categories: Tricks & Tips Tags: , , , ,

Android 4.0 source released!

November 16, 2011 3 comments

oh oh…Android 4.0 source code has been released!

And yes, lots of work to do for now 🙂

>> From :


Source Code Available for Android 4.0

The source code for the Android 4.0 platform and software stack has been released! This release allows OEMs to begin preparing Android 4.0 for installation on new and existing devices, and allows hobbyists, enthusiasts, and researchers to develop custom builds. For information on how to obtain the software, visit our Getting the Source page.



Categories: Of Diary Tags: , ,

How to Kill Your Application

November 1, 2011 Leave a comment

If your want to kill your application, there are three ways AFAIK:

>> Method #1


>> Method #2


>> Method #3

finish(); // one provided method of 'Activity' class

There’s an old usual method is to use `ActivityManager.restartPackage()`; however, it’s already deprecated from API Level 3, suggesting not to use it anymore.

If you know any other ways, feel free to share!

Pete Houston