Difference among XML SAX parser, Pull parser & DOM parser

Friday, October 12, 2012


Sax Parser : Simple API of XML Parse node to node, using top-down traversing, parse without storing xml, Faster compared to Dom Manipulating of node like insertion or deletion is allowed. Needs SAXParserFactory
Dom Parser : Document Object Model Stores entire xml in memory before processing, traverse in any direction, Manipulating of node like insertion or deletion is NOT allowed. Needs DocumentBuilderFactory
Pull Parser: It provides more control and speed from the above two.

XML parsing in android.

XML is a popular format for sharing data on the internet. Websites that frequently update their content, such as news sites or blogs, often provide an XML feed so that external programs can keep abreast of content changes. Uploading and parsing XML data is a common task for network-connected apps. This lesson explains how to parse XML documents and use their data.

This is the XML parser class:

Connection.java

How to parsing JSON in android.

Friday, September 28, 2012

I am taking an example of following JSON which will give you list of contacts and each contact will have details like name, email, address, phone number ertc,.


If you observe normally JSON data will have square brackets and curly brackets. The difference between [ and { is, the square bracket represents starting of an JSONArray node whereas curly bracket represents JSONObject. While accessing these elements we need to call different methods to access these nodes.


  • Writing JSON Parser Class

In your project create a class file and name it as JSONParser.java. The parser class has a method which will make http request to get JSON data and returns a JSONObject.

Integration of android application with twitter.

Thursday, September 27, 2012


Are you an Android developer who wants to integrate your app with Twitter so that your end user can:

1. Login with Twitter
2. Post messages to Twitter

It’s not so hard to achieve these two - if you know what you are doing. And the steps below should make it easy for you to achieve the desired results.


  • Setting up the Twitter account and application.
The basic steps are:

1. You have to create an Account on Twitter before you do anything.
2. Register you application with Twitter here (https://dev.twitter.com/user)
3. Create the Activity to enter your tweet

Integration of android application with facebook.

This tutorial is about integrating facebook into your android application. I am going to explain various steps like generating your application signature, registering facebook application, downloading facebook sdk and other steps.

  • Generating App Signature for Facebook Settings

To create facebook android native app you need to provide your Android application signature in facebook app settings. You can generate your application signature (keyhash) usingkeytool that comes with java. But to generate signature you need openssl installed on your pc. If you don’t have one download openssl from here and set it in your system environment path.
Open your command prompt (CMD) and run the following command to generate your keyhash. While generating hashkey it should ask you password. Give password as android. If it don’t ask for password your keystore path is incorrect.

keytool -exportcert -alias androiddebugkey -keystore "<path-to-users-directory>\.android\
debug.keystore" | openssl sha1 -binary | openssl base64

check the following command how i generated hashkey on my pc.

keytool -exportcert -alias androiddebugkey -keystore "C:\users\raj\.android\debug.keystore"
| openssl sha1 -binary | openssl base64


Android kSoap2 web service parsing Data.


Android kSoap2 web service Parsing Data
In this tutorial for Android ksoap2 web service . we can passing data through web service and store the data in web server.
how to read and parse JSON or XML, but another (pretty big) format is SOAP. In this post we will see how you make a application that reads and parses SOAP data into a Android application!
first we need ksoap2-android-assembly-2.5.6-jar file. download this jar file and put your workspace lib folder.

  • Just click the most recent version
  • search for the jar file with dependencies.
  • download it by right clicking the link "Raw file"
  • then clicking "Save as ...".
  • Save it inside your project folder so you can link it easily. 
Note: add the jar file to the project. ( Project properties -> Java build path -> Add JAR's )

Source code :

Load images from server in android.

Wednesday, September 26, 2012

This tutorial demonstrates how to load a remote image into your application and bind this image to an ImageView object. HttpURLConnection is used to download the image data and BitmapFactory is used to produce the bitmap which will be used as ImageView resource.

Java Code :


import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

public class HTTPTest extends Activity {
     

     ImageView imView;
     String imageUrl="http://11.0.6.23/";
     Random r= new Random();
    /** Called when the activity is first created. */ 
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
       
        Button bt3= (Button)findViewById(R.id.get_imagebt);
        bt3.setOnClickListener(getImgListener);
        imView = (ImageView)findViewById(R.id.imview);
    }    

How to display images to gridview from server in android

Tuesday, September 25, 2012


This code is help you to display image in grideview from server in android.

ViewImage.java

package com.gridview;


import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.widget.AdapterView;

import android.widget.GridView;

import android.widget.Toast;


public class MyGridView extends Activity {

    private GridView girGridView;

   @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);


        girGridView=(GridView) findViewById(R.id.gridView1_bir);


        girGridView.setAdapter(new ImageAdapter(this));


        girGridView.setOnItemClickListener(new AdapterView.OnItemClickListener()  {

       public void onItemClick(AdapterView<?> arg0, View view,                    int position,long arg3) {
      Toast.makeText(getApplicationContext(), GridViewConfig.getResim_list().
                 get(position), Toast.LENGTH_SHORT).show();

            }
        });

    }

}

Enable GPS programmatically in android.

Sunday, September 23, 2012


Here's some example code i use it help you.

private void turnGPSOn(){
    String provider = Settings.Secure.getString(getContentResolver(),
                      Settings.Secure.LOCATION_PROVIDERS_ALLOWED);

    if(!provider.contains("gps")){ //if gps is disabled
        final Intent poke = new Intent();
        poke.setClassName("com.android.settings", "com.android.
          settings.widget.SettingsAppWidgetProvider"); 
        poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
        poke.setData(Uri.parse("3")); 
        sendBroadcast(poke);
    }
}

How to generate google map key for android?


It is not only about the Android app keystore or the Android Maps API Key. It is a combination of both. We need the keystore when we want to sign a App.
The way you can sign a App is as follow; (I am giving instructions by assuming that you are working with Eclipse IDE)
  • Right click on your project in the Package Explorer window
  • Android Tools -> Export signed application package
  • In Project Checks window, brows your project and go to next window
  • There, select "Create new keystore" and follow the wizard
  • Don't give the default password which comes with the Eclipse debug key
Then you can finish creating a signed key for your app. Next procedure is Android Maps API Key Signup process. Here I am assume that you are doing implementation in a Windows environment

Tutorial for Sending And Reading SMS in android

Wednesday, April 4, 2012

 In this tutorial, you'll send a Message from thi application and also read Message which is forward by other person to you. In this you have to just write phone number and the message which you want to send. think this code is more helpfull to you.

Now, first of all create your android project and use this code for send Message.

Customise DatePicker and TimePicker Dialog in Android

Sunday, March 18, 2012

To provide a widget for selecting a date, use the DatePicker widget, which allows the user to select the month, day, and year, in a familiar interface.

In this tutorial, you'll create a DatePickerDialog, which presents the date picker in a floating dialog box at the click on the EditText box. When the date is set by the user, a EditText will update with the new date.

Also you can set TimePickerDialog similarly DatePickerDialog.

Splace screen tutorial for android

Saturday, March 17, 2012

Many Applications, mostly games, on the market show splash screens. With this screen they prompt a logo for the application and/or the author.

I will show you a short way to implement a splash screen which will occur on every startup, will stay for a number of seconds you can define, will close on touching the screen and will not reappear on pressing the back button.

I created an empty project named SplashScreen with the activity SplashScreen. This activity will display the splash screen, so we have to create a new activity which will be the first real view you want to display.

Sencha Touch Framework for Mobile Application

Friday, March 16, 2012

What is Sencha Touch?

Sencha Touch allows your web apps to look and feel like native apps. Beautiful user interface components and rich data management, all powered by the latest HTML5 and CSS3 web standards and ready for Android and Apple iOS devices. Keep them web-based or wrap them for distribution on mobile app stores.

What is Intent?

Monday, February 27, 2012

  • Definition: Intent (android.content.Intent) is an asynchronous message mechanism used by the Android operating system to match task requests with the appropriate Activity or Service (launching it, if necessary) and to dispatch broadcast Intents events to the system at large.
  • Package: android.content.Intent.
 How it is useful for transitioning between various activities?

  • Android app have multiple entry points, No main function.
  • One activity is designated as main / launcher activity in manifest file
  • To transition from one activity to other after creating instance call startActivity() method which has “Intent” instance as argument.

Tutorial for Building Your First Android Application

Creating and Configuring a New Android Project

You can create a new Android project in much the same way as when you added the
Snake application to your Eclipse workspace.

The first thing you need to do is create a new project in your Eclipse workspace.The
Android Project Wizard creates all the required files for an Android application. Follow
these steps within Eclipse to create a new project:

1. Choose File,New,Android Project, or choose the Android Project creator icon,
which looks like a folder (with the letter a and a plus sign), on the Eclipse
toolbar.

Android Debug Bridge (ADB)

Android Debug Bridge (ADB) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device. It is a client-server program that includes three components:

  • A client, which runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients.
  • A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device.
  • A daemon, which runs as a background process on each emulator or device instance.

An Android Virtual Device (AVD)

An Android Virtual Device (AVD) is an emulator configuration that lets you model an actual device by defining hardware and software options to be emulated by the Android Emulator.
An AVD consists of:
  •  A hardware profile: Defines the hardware features of the virtual device. For example, you can define whether the device has a camera, whether it uses a physical QWERTY keyboard or a dialing pad, how much memory it has, and so on.
  • A mapping to a system image: You can define what version of the Android platform will run on the virtual device. You can choose a version of the standard Android platform or the system image packaged with an SDK add-on.

Dalvik Debug Monitor Server (DDMS)

The Dalvik Debug Monitor Server (DDMS) is a command-line tool that has also been integrated into Eclipse as a perspective see in below figure.This tool provides you with direct access to the device—whether it’s the emulator virtual device or the physical device.You use DDMS to view and manage processes and threads running on the device, view heap data, attach to processes to debug, and a variety of other tasks.

Android ships with a debugging tool called the Dalvik Debug Monitor Server (DDMS), which provides port-forwarding services, screen capture on the device, thread and heap information on the device, logcat, process, and radio state information, incoming call and SMS spoofing, location data spoofing, and more.

Configuring Your Development Environment

To write Android applications, you must configure your programming environment for Java development.The software is available online for download at no cost.Android applications
can be developed on Windows, Macintosh, or Linux systems.

To develop Android applications, you need to have the following software installed on
your computer:
  •  The Java Development Kit (JDK) Version 5 or 6, available for download at http://java.sun.com/javase/downloads/index.jsp.

Android Platform Differences

Android is hailed as “the first complete, open, and free mobile platform”:
  •  Complete: The designers took a comprehensive approach when they developed the Android platform.They began with a secure operating system and built a robust software framework on top that allows for rich application development opportunities.
  •  Open: The Android platform is provided through open source licensing. Developers have unprecedented access to the handset features when developing applications.

Introducing Android

The mobile development community is at a tipping point. Mobile users demand more choice, more opportunities to customize their phones, and more functionality. Mobile operators want to provide value-added content to their subscribers in a manageable and lucrative way.

Mobile developers want the freedom to develop the powerful mobile applications users demand with minimal roadblocks to success. Finally, handset manufacturers want a stable, secure, and affordable platform to power their devices. Up until now a single mobile platform has adequately addressed the needs of all the parties.