问题描述
我开发一个Android应用程序应该与用户数据头检索SMS(UDH)。与UDH消息是标准的Android短信信使无形。我用06050415810000UDH用于测试(06 - 标题长度,05 - 报头类型,04 - 长度首部的其余1581 - 目的地端口,0000 - 的src端口)。设备与三星OS已检索消息,这样的标题和收件箱文件夹中显示的信息(但它无法打开该邮件)。设备与Android OS没有显示它(这是正常的),但我的应用程序不能赶上隐形短信。
我有以下的code赶上短信:
I am developing an Android application that should retrieve SMS with User Data Header (UDH). Messages with UDH are invisible for standard Android SMS messenger. I use "06050415810000" UDH for testing ("06" - header length, "05" - header type, "04" - length of the rest of the header, "1581" - destination port, "0000" - src port). Device with Samsung OS has retrieved message with such header and the message was shown in the Inbox folder (but it was not possible to open the message). Device with Android OS is not showing it (it's normal), but my app can't catch invisible SMS.I have the following code to catch SMS:
public class SmsReceiver extends BroadcastReceiver {
public Class<?> delegate = null;
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[])bundle.get("pdus");
final SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < pdus.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
}
AppManager.setSmsMessage(messages[0]);
if (delegate != null) {
Intent di = new Intent(context, delegate);
di.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
di.putExtra("SMS", messages[0].getPdu());
context.startActivity(di);
}
}
}
这是我的清单文件:
And this is my manifest file:
<receiver
android:name=".services.SmsReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.intent.action.DATA_SMS_RECEIVED"/>
</intent-filter>
</receiver>
该应用程序只检索邮件,而不UDH。
The app retrieve only messages without UDH.
任何想法?先谢谢了。
推荐答案
您需要的 RECEIVE_SMS
许可
<uses-permission android:name="android.permission.RECEIVE_SMS" />
这篇关于Retreive短信与Android设备上的用户数据报头(UDH)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!