Android 短信编程

发布于 2024-12-26 23:15:43 字数 150 浏览 4 评论 0原文

我是Android开发平台的新手。

第三方应用程序(比如我正在开发的应用程序)可以发送短信吗?

我相信我们无法访问默认的短信应用程序。因此,我计划自己开发一个,它将读取所使用的单词并在发送给接收者之前处理这些文本。我想知道是否有这样的API可以发送短信。

I'm a newbie on Android development platform.

Can a third party application (say the one I'm developing) send SMS messages?

I believe we do not have access to default text messaging app. Therefore I plan to develop one on my own, which will read words used and process such texts before delivering to receiver. I would like to know if there are such APIs which allow to send text messages.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

给妤﹃绝世温柔 2025-01-02 23:15:43

以下是一个可能有帮助的简单片段:

SmsManager smsMgr=SmsManager.getDefault();
String destination="9999119911";
String msg="Hello World";
smsMgr.sendTextMessage(destination,null,msg,null,null);

不要忘记添加

<uses-permission android:name="android.permission.SEND_SMS"/>

到 AndroidManifest.xml

测试:
您可以将短信从一个模拟器实例发送到另一个模拟器实例,为此,只需指定端口即可
作为目标的另一个实例的编号。
检查端口号:

$ /opt/android-sdk/platform-tools/adb devices

Here is a simple snippet that might help:

SmsManager smsMgr=SmsManager.getDefault();
String destination="9999119911";
String msg="Hello World";
smsMgr.sendTextMessage(destination,null,msg,null,null);

Don't Forget to add

<uses-permission android:name="android.permission.SEND_SMS"/>

to AndroidManifest.xml

Testing :
You can send SMS from one instance of emulator to another ,to do that ,simply specify the port
number of the other instance as destination .
to check the port number :

$ /opt/android-sdk/platform-tools/adb devices
无力看清 2025-01-02 23:15:43

http://thinkandroid.wordpress.com/2010/01/ 08/sending-sms-from-application/

我想这就是您正在寻找的。本文中描述的第二种方法不需要任何额外的权限,但它要求用户键入消息。我认为没有办法在未经许可的情况下发送短信。

http://thinkandroid.wordpress.com/2010/01/08/sending-sms-from-application/

I think this is what you are looking for. The second method described in the article does not need any additional permissions, but it requires that the user types the message. I don't think there is a way to send an SMS without the permission.

旧时浪漫 2025-01-02 23:15:43

一个很好的起点是这里 http://developer.android.com/reference/ android/telephony/SmsManager.html

如果您想在应用程序中包含 SMS 功能,则需要使用 SmsManager 类。

A good place to start is here http://developer.android.com/reference/android/telephony/SmsManager.html

You need to use the SmsManager class, if you want to include SMS capability in your app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文