I tried to get the message id that is stored on the phone. But I did not succeed. 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(); } }
Under this, I get the sms body and sender number. But I know that for each message in the Android phone there is a unique number, I extracted it. But it was not possible to receive in methods onReceive. Thanks
Ashekur Rahman Molla Asik
source share