如何接收文本短信到特定端口.. [英] how to receive text sms to specific port..

查看:138
本文介绍了如何接收文本短信到特定端口..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何接收文本短信到特定端口?我一直在寻找一个回答这个问题,但都无济于事。这已经被问了几次,但似乎没有人有一个明确的答案。我的code是如下:

How to receive text sms to a specific port? I have been looking for an answer to this question but to no avail. This has been asked a few times but nobody seems to have a clear answer. My code is as follows:

- 清单FILE--

--MANIFEST FILE--

<receiver android:name=".SMSRecieve" android:enabled="true"> 
<intent-filter> 
<action android:name="android.intent.action.DATA_SMS_RECEIVED"/> 
<data android:scheme="sms" /> 
<data android:host="localhost" /> 
<data android:port="15005" /> 
</intent-filter> 
</receiver>

- 短信发送method--

--SMS sending method--

String messageText = msgTxt.getText().toString(); 
short SMS_PORT = 15005; 
SmsManager smsManager = SmsManager.getDefault(); 
smsManager.sendDataMessage("5556", null, SMS_PORT, messageText.getBytes(), null, null); 

- 广播接收器code--

--Broadcast Receiver code--

static final String ACTION = "android.intent.action.DATA_SMS_RECEIVED"; 
//static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";(tried this too, but failed) 

if (intent.getAction().equals(SMSNotifyExample.ACTION)) { 
...do some work.. 
}

我也试过来替换安卓名称 android.provider.Telephony.SMS_RECEIVED 但结果是相同。

I also tried to replace android:name to android.provider.Telephony.SMS_RECEIVED but the result is the same.

我的应用程序不接受指定端口上的短信。有一次,我删除以下行正常工作:

My application does not receive the SMS on the specified port. Once I remove the following line it works fine:

<data android:scheme="sms" /> 
<data android:host="localhost" /> 
<data android:port="15005" /> 

你能建议我缺少什么?

Could you suggest what am I missing?

推荐答案

谢谢你的提示!

我用这个和它的作品:

        <receiver android:name=".SMSReceiver">
        <intent-filter android:priority="10">
        <action android:name="android.intent.action.DATA_SMS_RECEIVED" />
            <data android:scheme="sms" />
            <data android:port="50009" />
        </intent-filter>
    </receiver>

这篇关于如何接收文本短信到特定端口..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆