Get recipient number from SMS in Android -


this may sound strange want number i've received sms on, on phone. can mobile number sim present inside telephonymanager.getline1number() (although not guaranteed i'll phone number). in case have 2 sims present in phone. telephonymanager.getline1number() return me sim info first/active sim only.

edited : tried info whenever receive sms, not find interesting.

so there way recipient's number (and not sender's number) sms received?

try code,

public class smsreceiver extends broadcastreceiver {     

@override public void onreceive(context context, intent intent) {

bundle extras = intent.getextras(); if (extras == null) return; object[] pdus = (object[]) extras.get("pdus"); string[] fromaddress = new string[pdus.length]; smsmessage[] message = new smsmessage[pdus.length]; (int = 0; < pdus.length; i++) { message[i] = smsmessage.createfrompdu((byte[])pdus[i]); fromaddress[i] = message[i].getoriginatingaddress(); // give address sms originated. }

}


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -