Sunday, February 23, 2014

Create simple application in Android to send SMS

Hello friends, today we will learn to create simple application (app) in Android for sending SMS.
Some pre-requisites for this application are:
1)   Download adtbundle for Android development from http://developer.android.com/sdk/index.html
2)   Unzip it and copy and paste it in
C:\Program Files\
3)   Open eclipse and double click on eclipse.exe

Now you are ready steady to go for your first app experience.

Step 1: Create new project by going to
File>new>Android application project
Then the following screen will appear

[figure 1: New Android Application screen]
Fill up all the details which are blank on the screen. We will name our application as JAKSMS, project name SendsmsDemo, package name com.example.sendsmsdemo. Then click next>next>next>next>finish, and by following these simple steps we have created our first default app.

Step 2: Run this project by creating new Android Virtual Device (AVD). Go to window>Android Virtual Device Manager>new>
Give appropriate name to your AVD and select the lowest level device and click ok, this will create your AVD. Select your newly created AVD and click start.

Step 3: Now we will modify this first app of ours for sending SMS through our app.
For this we have to modify few files
1)    MainActivity.java
2)    activity_main.xml
3)    strings.xml
4)    AndroidManifest.xml


                   ·        MainActivity.java

[figure 2: packages to include in MainActivity.java]
[figure 2.1: MainActivity class and onCreate() method]
[figure 2.2: user defined method sendSMS()]


·        activity_main.xml
[ figure 3: main.xml file]


·        strings.xml



[figure 4: strings.xml file]

·        AndroidManifest.xml
[ figure 5: AndroidManifest.xml file]
Step 4: Save this project and run it in AVD
·        Output
[ figure 5: Output on AVD]

No comments:

Post a Comment