Thursday, February 28, 2013

Android Application to get Pincode from Place

Download the Android application for Pincode Search

Step1: Download the Pincode Search Android App in India from here.

Step2: You need to download the application or copy the file to your mobile.

step3: Since the application is not there in Android Market, you need to mobile phone: Settings -> Applications -> select the Unknown sources

step4: Double click the dowloaded file in mobile and install

step5: In your application window you will get logo for the application and it will direct you to the respective screen and sites when you click on the tabs, but you need to have internet connection in Mobile

Design
The pincode API can be get from www.getpincode.info , the components are attached to the Screen1 which include a Web component,Place search text box and search button. Activity starter is used for the button like Índia Post' and Speed Post to connect to internet.


Android AppInventor JSON response parsing

The Web component can be used to connect and get the response which is in JSON format. Once the Url has been set in text , the web1.get can be called to receive the JSON response.


Appinventor Web.GotText
The response content needs to be passed to a procedurewithResult( can be created from the definition block. Procedure which returns a value). The procedure has been defined with four parameters jsonresponse, starttag,endtag and decodeHTMLText. The procedure is called with responsecontent,"pincode", "," and true.


App Inventor Procedure to parse JSON response

The created temporary variable can be assigned with response , but we need to parse it based on the instruction given in www.getpincode.info . using startTag we can split the response into two pieces in that we need to again split the data again with endTag. If there is any html code , we need to decode it that as well.

1 comment: