Below is an example of how you can share or send an SMS programmatically via an Android Intent,
- Create an object on Intent object with Intent.ACTION_VIEW and Uri,
- Using putExtra provide the sms body
- Start the activity
Intent message = new Intent( Intent.ACTION_VIEW, Uri.parse( "sms:" + "" ) );
message.putExtra( "sms_body", "Put your SMS text here" );
startActivity(message);
Note: You would require to have permissions enabled to SEND SMS, this can be done by adding the below code in Manifest,
<uses-permission android:name="android.permission.SEND_SMS" />
If you want to sent an MMS you may have to use some more options,
public void sendSmsMessage(String sms, Uri attachment) {
Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
msIntent.setType(HTTP.PLAIN_TEXT_TYPE);
msIntent.putExtra("sms_body", "hey there, this is an test SMS");
msIntent.putExtra(Intent.EXTRA_STREAM, attachment);
startActivity(intent);
}
Actions can be among: ACTION_SENDTO, ACTION_SEND or ACTION_SEND_MULTIPLE
URI Schema's: sms:<phone_number>, smsto:<phone_number>, mms:<phone_number>, mmsto:<phone_number>
MIME Types could be like: "text/plain", "image/*", "video/*"
- Android Error Unexpected cast to Button: layout tag was FrameLayout
- ADT quit unexpectedly error on Mac OSX Android Eclipse SDK
- Parsing Data for android-21 failed unsupported major.minor version 51.0
- Android Studio Ctrl Shift o auto import not working
- java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android : How to make TextView Scrollable
- This class should be public (android.support.v7.internal.widget.ActionBarView.HomeView) Lint Error
- Integrating Android Facebook SDK 3.17.2 Tutorial
- Android R Cannot Be Resolved To A Variable
- Android : Exception raised during rendering: action_bar API 22
- How to take screenshot on Android
- Read Text file from SD Card : Android Programming
- How to make Android EditText not editable
- Your Android SDK is out of date or is missing templates. Please ensure you are using SDK version 22 or later.
- The declared package does not match the expected package Eclipse
- Can't Run SDK Manager find_java.bat issue
- What is Android Toast.LENGTH_SHORT and Toast. LENGTH_LONG durations
- Android Emulator Soft Back button action using Computer keyboard
- Multiline EditText in Android Example
- Use 5G Network on Android Emulator
- Make Android TextView Clickable like Buttons
- How to empty trash in Android Device
- Android : Execute some code after back button is pressed
- Disable Fading Edges Scroll Effect Android Views
- How To Disable Landscape Mode in Android Application
- [Solutions] Android Error in an XML file: aborting build. Eclipse SDK - Android
- Restore deleted Office 365 SharePoint group site - SharePoint
- [Solution] The connection to the remote PC was lost, preparing to reconnect - Windows RDP - Windows
- What is CA FE BA BE 00 00 00 3D in Java Class Bytecode - Java
- Android Wifi WPA2/WPA Connects and Disconnects issue - Android
- Steps to Compare Two files in Sublime Text Side-by-Side - Sublime-Text
- Using Document Map in Notepad++ - NotepadPlusPlus
- macOS Ventura XCode Command Line Tools Installation - MacOS