0% found this document useful (0 votes)
12 views4 pages

Android SMS Code

The document contains the code for an Android application that allows users to send SMS messages. It includes the layout file 'activity_main.xml' for the user interface, 'MainActivity.java' for the functionality to send SMS, and 'AndroidManifest.xml' for permissions and application configuration. The app features input fields for mobile number and message, and a button to send the SMS using the SmsManager class.

Uploaded by

abcyadav3732
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Android SMS Code

The document contains the code for an Android application that allows users to send SMS messages. It includes the layout file 'activity_main.xml' for the user interface, 'MainActivity.java' for the functionality to send SMS, and 'AndroidManifest.xml' for permissions and application configuration. The app features input fields for mobile number and message, and a button to send the SMS using the SmsManager class.

Uploaded by

abcyadav3732
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

activity_main.

xml
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="[Link]

android:orientation="vertical" android:layout_width="match_parent"

android:layout_height="match_parent">

<TextView

android:id="@+id/fstTxt"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="100dp"

android:layout_marginTop="150dp"

android:text="Mobile No" />

<EditText

android:id="@+id/mblTxt"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="100dp"

android:ems="10"/>

<TextView

android:id="@+id/secTxt"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Message"

android:layout_marginLeft="100dp" />

<EditText

android:id="@+id/msgTxt"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="100dp"

android:ems="10" />

<Button
android:id="@+id/btnSend"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="100dp"

android:text="Send SMS" />

</LinearLayout>

[Link]
package [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class MainActivity extends AppCompatActivity

private EditText txtMobile;

private EditText txtMessage;

private Button btnSms;

@Override

protected void onCreate(Bundle savedInstanceState) {

[Link](savedInstanceState);

setContentView([Link].activity_main);
txtMobile = (EditText)findViewById([Link]);

txtMessage = (EditText)findViewById([Link]);

btnSms = (Button)findViewById([Link]);

[Link](new [Link]() {

@Override

public void onClick(View v) {

try{

SmsManager smgr = [Link]();

[Link]([Link]().toString(),null,[Link]().toString(

),null,null);

[Link]([Link],

Toast.LENGTH_SHORT).show();

catch (Exception e){

"SMS

Sent

Successfully",

[Link]([Link], "SMS Failed to Send, Please try again",

Toast.LENGTH_SHORT).show();

});

[Link]
<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="[Link]

package="[Link]">

<uses-permission android:name="[Link].SEND_SMS"/>
<application

android:allowBackup="true"

android:icon="@mipmap/ic_launcher"

android:label="@string/app_name"

android:roundIcon="@mipmap/ic_launcher_round"

android:supportsRtl="true"

android:theme="@style/AppTheme">

<activity android:name=".MainActivity">

<intent-filter>

<action android:name="[Link]" />

<category android:name="[Link]" />

</intent-filter>

</activity>

</application>

</manifest>

You might also like