Sending SMS on Android

Hey, I'm making an Android app that needs to send a text message. Here is the current code that I have:

public class getMessage extends Service {
@Override
public IBinder onBind(Intent intent) {
    return null;
}

@Override
public void onStart(Intent intent, int startId) {
    super.onStart(intent, startId);

    client Phone = new client();


    String[] msg = Phone.getMsg(user[0],user[1]);
    PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, getMessage.class), 0);
    SmsManager man = SmsManager.getDefault();
    Log.e("GOT MESSAGE", msg[0]+ " : " +msg[1]);
    man.sendTextMessage(msg[0], null, msg[1], pi, null);
    Log.e("Message", "Sent the message?");
}

Now for some reason, the text message will not send this code, and I'm not sure why. I was hoping someone here could help me find out why this message was not sent.

The error does not occur, nothing is displayed in the log (except for the log messages that I do myself in the code). In addition, there are valid tags in the manifest.

Suggestions?

+5
source share
3 answers

OK, now it's awkward. Apparently, the way I did this was correct. Just that I checked if it was sent was clearly wrong.

, . , .

, !

+2

, SMS.

+3

does this link help ? It basically goes through selective activity, which sends and listens to SMS messages.

+1
source

All Articles