支持彩信发送报告提示

支持彩信发送报告提示

[DESCRIPTION]

需求:在发送完彩信后,若有发送报告的需求,将弹出提示:“***已接收”

[SOLUTION]

请在PushReceiver.JAVA 中,当接收到MESSAGE_TYPE_DELIVERY_IND 时,从Pdu中获取联系人号码,并新建一个thread 去show,具体修改参考如下(GB3的代码为例,其他平台也是类似的):
在PushReceiver.java 中导入:
import com.google.Android.mms.pdu.EncodedStringValue;
import andriod.widget.Toast;
import android.os.Handler;
将doInBackground(Intent... intents) 方法修改如下:
try {
switch (type) {
case MESSAGE_TYPE_DELIVERY_IND:
Xlog.d(MmsApp.TXN_TAG, "type=MESSAGE_TYPE_DELIVERY_IND");
case MESSAGE_TYPE_READ_ORIG_IND: {
Xlog.d(MmsApp.TXN_TAG, "type=MESSAGE_TYPE_READ_ORIG_IND");
threadId = findThreadId(mContext, pdu, type);
if (threadId == -1) {
// The associated SendReq isn't found, therefore skip
// processing this PDU.
break;
}
Uri uri = p.persist(pdu, Inbox.CONTENT_URI);
// Update thread ID for ReadOrigInd & DeliveryInd.
ContentValues values = new ContentValues(1);
values.put(Mms.THREAD_ID, threadId);
SqliteWrapper.update(mContext, cr, uri, values, null, null);
if(type==MESSAGE_TYPE_DELIVERY_IND){
Xlog.d (MmsApp.TXN_TAG, "MTK show delivery toast");
//MessagingNotification.blockingUpdateNewMessageIndicator(PushReceiver.this, false,
true);
final long timeMillis = 3000;
//String address = pdu.getFrom().getString();
String getTo = (EncodedStringValue.concat(((DeliveryInd)pdu).getTo()));
Xlog.d (MmsApp.TXN_TAG, "MTK type=MESSAGE_TYPE_DELIVERY_IND sendTo=" +
getTo);
final String message1 = mContext.getString(R.string.delivery_toast_body,getTo) ;
mToastHandler.post(new Runnable() {
public void run() {
Toast.makeText(mContext, message1, (int)timeMillis).show();
}
});
//Toast.makeText(this, message1, (int)timeMIllis).show;
}
break;
}


你可能感兴趣的:(MTK)