开发者

Correct way to send SMS messages through Android

开发者 https://www.devze.com 2023-02-13 11:16 出处:网络
Hello Stack Overflow Community, So I have searched all over the net for a solution to this, but cannot find someone with a similar problem...

Hello Stack Overflow Community,

So I have searched all over the net for a solution to this, but cannot find someone with a similar problem...

I am writing a small program that receives texts and responds to them. The receiving portion works fine, but I have yet to send a successful text. The small test program below has produced the same results. Below is the method that I used to try and send along with a snippet of the logcat. The sendTextMessage method has produced absolutely nothing. I have been testing this over my LG Ally not the emulator. I just thought I would ask if there is something I'm missing before I decide it is just the phone.

Notes... The permissions are set correctly. Obviously the "xxxxxxxxxx" represents an actual number.

Thanks in advance,

Jason

package com.test;

import androi开发者_StackOverflowd.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.util.Log;

public class test extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Log.w("MARK", "APPLICATION START");
        SmsManager sms = SmsManager.getDefault();
        sms.sendTextMessage("xxxxxxxxxx", null, "AUTO RESPONSE", null, null);
        Log.w("MARK", "sendTextMessage CALLED");
    }
}

02-27 12:42:02.471: WARN/MARK(9903): APPLICATION START
02-27 12:42:02.471: WARN/MARK(9903): sendTextMessage CALLED
02-27 12:42:02.591: INFO/ActivityManager(1372): Displayed activity com.test/.test: 135 ms (total 135 ms)


Starting activity using sms intent will invoke an editor and wait for user to press Send button. To do it programatically, try using SmsManager

0

精彩评论

暂无评论...
验证码 换一张
取 消