n Android, you can use
P.S This project is developed in Eclipse 3.7, and tested with Samsung Galaxy S2 (Android 2.3.3).
File : res/layout/main.xml
File : SendSMSActivity.java – Activity to send SMS via
File : AndroidManifest.xml , need SEND_SMS permission.
See demo :
File : res/layout/main.xml – A button only.
File : SendSMSActivity.java – Activity class to use build-in SMS intent to send out the SMS message.
See demo :
SmsManager
API or device’s Built-in SMS
application to send a SMS message. In this tutorial, we show you two basic examples to send SMS message :- SmsManager API
SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage("phoneNo", null, "sms message", null, null);
- Built-in SMS application
Intent sendIntent = new Intent(Intent.ACTION_VIEW); sendIntent.putExtra("sms_body", "default content"); sendIntent.setType("vnd.android-dir/mms-sms"); startActivity(sendIntent);
<uses-permission android:name="android.permission.SEND_SMS" />
Note
The Built-in SMS application solution is the easiest way, because you let device handle everything for you.
The Built-in SMS application solution is the easiest way, because you let device handle everything for you.
1. SmsManager Example
Android layout file to textboxes (phone no, sms message) and button to send the SMS message.File : res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/textViewPhoneNo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Enter Phone Number : " android:textAppearance="?android:attr/textAppearanceLarge" /> <EditText android:id="@+id/editTextPhoneNo" android:layout_width="fill_parent" android:layout_height="wrap_content" android:phoneNumber="true" > </EditText> <TextView android:id="@+id/textViewSMS" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Enter SMS Message : " android:textAppearance="?android:attr/textAppearanceLarge" /> <EditText android:id="@+id/editTextSMS" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="textMultiLine" android:lines="5" android:gravity="top" /> <Button android:id="@+id/buttonSend" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Send" /> </LinearLayout>
SmsManager
.package com.mkyong.android; import android.app.Activity; import android.os.Bundle; import android.telephony.SmsManager; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class SendSMSActivity extends Activity { Button buttonSend; EditText textPhoneNo; EditText textSMS; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); buttonSend = (Button) findViewById(R.id.buttonSend); textPhoneNo = (EditText) findViewById(R.id.editTextPhoneNo); textSMS = (EditText) findViewById(R.id.editTextSMS); buttonSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String phoneNo = textPhoneNo.getText().toString(); String sms = textSMS.getText().toString(); try { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNo, null, sms, null, null); Toast.makeText(getApplicationContext(), "SMS Sent!", Toast.LENGTH_LONG).show(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "SMS faild, please try again later!", Toast.LENGTH_LONG).show(); e.printStackTrace(); } } }); } }
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mkyong.android" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" /> <uses-permission android:name="android.permission.SEND_SMS" /> <application android:debuggable="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:label="@string/app_name" android:name=".SendSMSActivity" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
2. Built-in SMS application Example
This example is using the device’s build-in SMS application to send out the SMS message.File : res/layout/main.xml – A button only.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:id="@+id/buttonSend" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Send" /> </LinearLayout>
package com.mkyong.android; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; public class SendSMSActivity extends Activity { Button buttonSend; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); buttonSend = (Button) findViewById(R.id.buttonSend); buttonSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { Intent sendIntent = new Intent(Intent.ACTION_VIEW); sendIntent.putExtra("sms_body", "default content"); sendIntent.setType("vnd.android-dir/mms-sms"); startActivity(sendIntent); } catch (Exception e) { Toast.makeText(getApplicationContext(), "SMS faild, please try again later!", Toast.LENGTH_LONG).show(); e.printStackTrace(); } } }); } }
Download Source Code
Download it – 1. Android-Send-SMS-Example.zip (16 KB)
Download it – 2. Android-Build-In-SMS-Application-Example.zip (16 KB)
The article is good to read and worth sharing
ReplyDeletesms message
I want to add the innovation that you have not specified. Due to the service http://www.intistele.com/ you can activate the integration with SMS API on any programming language. Now to inform about new promotions just got easier.
ReplyDeletejianbin1205
ReplyDeletecheap uggs
north face outlet online
coach outlet online
uggs outlet
snapback hats
true religion outlet,true religion jeans,true religion kids,true religion jeans sale,true religion jeans for men,true religion jacket,true religion sale
cheap oakley sunglasses
moncler coats
ugg boots on sale
cyber monday
kobe bryants shoes 2015
polo ralph lauren uk
moncler outlet
lululemon outlet
prada outlet
chanel handbags
ugg uk outlet
toms outlet
canada goose outlet
the north face jackets
new england patriots
chicago blackhawks
michael kors outlet sale
new york giants
air force one shoes
nike air max 90
ugg boots
air jordan 11 free shipping
michael kors handbags
nike trainers uk
air jordan shoes
kansas city chiefs
chicago bulls
IVR systems remain an efficient tool for routine inbound inquiries, as well as common outbound notifications like appointment reminders. You can also use an IVR system sms plugin
ReplyDeleteBurberry Outlet
ReplyDeleteOakley Eyeglasses Michael Kors Outlet Coach Factory Outlet Coach Outlet Online Coach Purses Kate Spade Outlet Toms Shoes North Face Outlet Coach Outlet Gucci Belt North Face Jackets Oakley Sunglasses Toms Outlet North Face Outlet Nike Outlet Nike Hoodies Tory Burch Flats Marc Jacobs Handbags Jimmy Choo Shoes Jimmy Choos
Burberry Belt Tory Burch Boots Louis Vuitton Belt Ferragamo Belt Marc Jacobs Handbags Lululemon Outlet Christian Louboutin Shoes True Religion Outlet Tommy Hilfiger Outlet
Michael Kors Outlet Coach Outlet Red Bottoms Kevin Durant Shoes New Balance Outlet Adidas Outlet Coach Outlet Online Stephen Curry Jersey
longchamp handbags
ReplyDeletegolden goose sneakers
golden goose sneakers
supreme clothing
supreme clothing
kyrie 7 shoes
kobe
stone island sale
nike x off white
kenzo
check this q7e39j0r03 bag replica high quality replica bags in bangkok x7h35m9l43 get more t9f79k4h06 replica louis vuitton bags replica bags wholesale in divisoria a3o79z9m77 replica bags louis vuitton official site l3y58y7p29 replica bags vancouver
ReplyDelete