MilkBottle
MilkBottle

Reputation: 4332

It is possible to auto send SMS for Android

I am not sure if this question appropriate as I new to Android. I am thinking to solve a problem such that when I am driving I want my Android to Auto send or Auto reply any incoming SMS. Would appreciate if you can guide me or provide me some tutorial or code on this. Can this task be accomplished in Android? Thanks.

Upvotes: 0

Views: 2819

Answers (5)

Eman Jayme
Eman Jayme

Reputation: 230

sendButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
                    int hasSMSPermission = checkSelfPermission(SEND_SMS);
                    if (hasSMSPermission != PackageManager.PERMISSION_GRANTED) {
                        if (!shouldShowRequestPermissionRationale(SEND_SMS)) {
                            showMessageOKCancel("You need to allow access to Send SMS",
                                    new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                                                requestPermissions(new String[] {SEND_SMS},
                                                        REQUEST_SMS);
                                            }
                                        }
                                    });
                            return;
                        }
                        requestPermissions(new String[] {SEND_SMS},
                                REQUEST_SMS);
                        return;
                    }
                    sendMySMS();
                }
            }
        });

sendButton.performClick();

Source: https://github.com/delaroy/SendSms/blob/master/app/src/main/java/com/delaroystudios/sendsms/MainActivity.java

just add "sendButton.performClick()" after the listener. I tried it.

Upvotes: 0

Eman Jayme
Eman Jayme

Reputation: 230

sendButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
                    int hasSMSPermission = checkSelfPermission(SEND_SMS);
                    if (hasSMSPermission != PackageManager.PERMISSION_GRANTED) {
                        if (!shouldShowRequestPermissionRationale(SEND_SMS)) {
                            showMessageOKCancel("You need to allow access to Send SMS",
                                    new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                                                requestPermissions(new String[] {SEND_SMS},
                                                        REQUEST_SMS);
                                            }
                                        }
                                    });
                            return;
                        }
                        requestPermissions(new String[] {SEND_SMS},
                                REQUEST_SMS);
                        return;
                    }
                    sendMySMS();
                }
            }
        });

sendButton.performClick();

Upvotes: 0

Mars Gao
Mars Gao

Reputation: 69

  1. You can try Android Accessibility Service.

https://developer.android.com/guide/topics/ui/accessibility/index.html

With the accessibility service in android you can get the current screen and can make the system to click buttons or send SMS automatically for you.

It can get the current screen and click into SMS, get the text box and set text, and click the send button at the end.

  1. There is a useful repo is found is

https://github.com/PrivacyStreams/PrivacyStreams

You can add this build.gradle into your project and get the text box with just a few lines.

Upvotes: 0

Talha
Talha

Reputation: 699

You can use this for sending message, but for this first you need to set permission in android menifest file

 SmsManager smsManager = SmsManager.getDefault();
                smsManager.sendTextMessage(phoneNumber, null,, smsText, null, null);

See this tutorial for incoming messages or calls: Android BroadcastReceiver Tutorial

Upvotes: 0

Emmanuel
Emmanuel

Reputation: 216

You could use the Google Cloud Messaging (GCM) service, and each time you get an incoming message get a reply from the server. Each time you get a reply from the GCM server with the broadcastevevent you could send a auto reply.

Upvotes: 1

Related Questions