0% found this document useful (0 votes)
6 views2 pages

SMS Manager - Full Java Program

This document is an Android application code for sending SMS messages. It includes functionality to send SMS directly and to open the SMS app with pre-filled details. The app checks for necessary permissions and handles user input for the recipient's number and message content.

Uploaded by

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

SMS Manager - Full Java Program

This document is an Android application code for sending SMS messages. It includes functionality to send SMS directly and to open the SMS app with pre-filled details. The app checks for necessary permissions and handles user input for the recipient's number and message content.

Uploaded by

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

package [Link].

firstmadproject;

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link];

import [Link];
import [Link];
import [Link];

public class smsManagerActivity extends AppCompatActivity {


EditText rn, msg;
Button btnSend, btnOpenSms;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link]);
btnSend = findViewById([Link]);
btnOpenSms = findViewById([Link]);
rn = findViewById([Link]);
msg = findViewById([Link]);

[Link](new [Link]() {
@Override
public void onClick(View v) {
String number = [Link]().toString();
String message = [Link]().toString();

if ([Link]() || [Link]()){
[Link]([Link], "Number and/or message cannot be
Empty!", Toast.LENGTH_SHORT).show();
}else{
if ([Link]([Link],
[Link].SEND_SMS) != PackageManager.PERMISSION_GRANTED) {
[Link]([Link],
new String[]{[Link].SEND_SMS}, 1);
} else {
sendSMS(number, message);
}
}
}
});
[Link](new [Link]() {
@Override
public void onClick(View v) {
String number = [Link]().toString();
String message = [Link]().toString();

Intent i = new Intent(Intent.ACTION_VIEW);


[Link]([Link]("[Link] + number));
[Link]("sms_body", message);
startActivity(i);
}
});
}
private void sendSMS(String number, String message) {
try{
SmsManager smsManager = [Link]();
[Link](number, null, message, null, null);
[Link](this, "SMS sent successfully!", Toast.LENGTH_LONG).show();
}

catch (Exception e) {
[Link](this, "SMS failed to send!", Toast.LENGTH_LONG).show();
[Link]();
}
}
}

You might also like