Sending SMS Messages in Android

Damith's Blog

This is a simple example can be used to send SMS in android devices. In here i have created two emulators and i will send sms from one emulator to another. I have not tested the code in a real device and i am sure it will work without any errors. This example extracted from the   http://stackoverflow.com/questions/5944345/sending-sms-in-android.

Java code looks like below

/* * Source : http://stackoverflow.com/questions/5944345/sending-sms-in-android * * */ package com.sms; import android.app.Activity; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.telephony.SmsManager; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Main extends Activity { private Button btnSend; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); btnSend = (Button)findViewById(R.id.btnSend); btnSend.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { sendSMS("5556", "test"); } }); } /** * This method can be used to send SMS from android * @param phoneNumber…

View original post 190 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s