I have tried to get a message id which is saved in phone. But I failed to get it. My existing code is here
@Override
public void onReceive(Context context, Intent intent) {
String address = "";
String message = "";
String msg_id="";
Bundle extras = intent.getExtras();
if (extras != null) {
Object[] smsExtra = (Object[]) extras.get("pdus");
for (int i = 0; i < smsExtra.length; i++) {
SmsMessage sms = SmsMessage.createFromPdu((byte[]) smsExtra[i]);
message += sms.getMessageBody();
address = sms.getOriginatingAddress();
}
sms = new Sms(msg_id,message, address);
UploadSms up = new UploadSms();
up.start();
Toast.makeText(context,
"SMS Received>>" + message + "From >>" + address,
Toast.LENGTH_LONG).show();
}
}
By this I get sms body and sender number. But I know there exist a unique number for every message in android phone, I retrieved it. But unable to retrieved in onReceive methods. Thanks
from Get message thread id or _id from onReceive android
No comments:
Post a Comment