开发者

Which class should we use for sending sms/text messages?

开发者 https://www.devze.com 2022-12-14 16:25 出处:网络
What class can we use to send a text message? I tried this on the emulator, 2.0: import android.telephony.SmsManager;

What class can we use to send a text message? I tried this on the emulator, 2.0:

import android.telephony.SmsManager;
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(...);

and that works ok. On my G1 running 1.5, I get a verify error, guessing because SmsManager is not available in 1.5. Maybe for 1.5 we need to use the deprecated class?:

android.telephony.gsm.SmsManager

is that co开发者_开发问答rrect, or is there some other class we're supposed to use for sending text messages?

Thanks


Correct. android.telephony.SmsManager is only available for API level 4 and up (a.k.a Android 1.6). See the docs. You can use Android.os.Build.Version to figure out which to use on a given platform.

0

精彩评论

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

关注公众号