跟踪短信的发送的Andr​​oid [英] Keeping track of sms sent in Android

查看:113
本文介绍了跟踪短信的发送的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到跟踪挂起的意图,我在通过Android的标准SmsManager送出去似乎并没有保留他们的额外信息。例如:

I'm noticing the tracking pending intents that I send out via the standard SmsManager in Android doesn't seem to retain the extra information in them. Example:

Intent sentIntent = new Intent(SENT);
sentIntent.putExtra("value1", "foo"); // <- note this value
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, sentIntent, 0);

SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(numberToSendTo, null, mMessageToSend, sentPI, null);

//... in the broadcastReceiver that catches the SENT intent ...
public void onReceive(Context arg0, Intent arg1) {

    arg1.getExtras().getString("value1");  // <- nothing, no such key
}

有人可以测试了这一点,这是有意的行为,我做错了,或者这是要申请的Andr​​oid的错误?

Can someone test this out, was this behaviour intended and I am doing it wrong, or is this a bug to be filed for Android?

推荐答案

尝试添加标志的 FILL_IN_SELECTOR 当您创建的PendingIntent(见<一个规范href=\"http://developer.android.com/reference/android/app/PendingIntent.html#getBroadcast%28android.content.Context,%20int,%20android.content.Intent,%20int%29\"相对=nofollow> PendingIntent.getBroadcast 的标志和他们的一般行为)。这应该强制的PendingIntent 采取所有顶级演员的意图

Try adding the flag FILL_IN_SELECTOR when you create the PendingIntent (see the spec for PendingIntent.getBroadcast for the flags and their general behavior). This should force the PendingIntent to take in all the top-level extras from the Intent.

这篇关于跟踪短信的发送的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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