开发者

Accessing the inbox in android application

开发者 https://www.devze.com 2023-02-20 16:43 出处:网络
I am developing an android message based ap开发者_如何学Goplication in which i have to access inbox programatically.Can anyone tell how should i pursueThere is no documented and supported API in the A

I am developing an android message based ap开发者_如何学Goplication in which i have to access inbox programatically.Can anyone tell how should i pursue


There is no documented and supported API in the Android SDK for accessing any sort of "inbox".


You should implement broadcast rceiver on "android.provider.Telephony.SMS_RECEIVED" Action.

After that read message data from intent:

Object[] pduArray = (Object[]) intent.getExtras().get("pdus"); 

SmsMessage[] messages = new SmsMessage[pduArray.length]; 

StringBuilder messageText = new StringBuilder();

for (int i = 0; i < pduArray.length; i++) {                 
     messages[i] = SmsMessage.createFromPdu((byte[])pduArray [i]);              
     messageText.append(messages[i].getMessageBody());          
} 
0

精彩评论

暂无评论...
验证码 换一张
取 消