开发者

Handling SMS BroadcastReceiver into Another Acitivity

I have an Inbox class which extends ActivityGroup implements OnItemClickListener. This inbox class has a menuItem name GET, when GET is called i have a method name GETSMS();

Now i have this class:

public class InboxSMSReciever extends BroadcastReceiver{
List<String> inboxEmails;
@Override
public void onReceive(Context context, Intent intent) {
    inboxEmails = new ArrayList<String>();;
    inboxEmails = getSMSAsEmails(intent);
}

private List<String> getSMSAsEmails(Intent intent){
    List<String> inboxEmails = new ArrayList<String>();
    Bundle bundle = intent.getExtras();
    SmsMessage[] smsMessage=null;
    if(bundle !=null){
          Object[] pdus = (Object[]) bundle.get("pdus");
          smsMessage = new SmsMessage[pdus.length];
          for(int i=0;i<smsMessage.length;i++){
              smsMessage[i]=SmsMessage.createFromPdu((byte[])pdus[i]);
              inbox开发者_如何学运维Emails.add(smsMessage[i].getMessageBody());
          }
    }
    return inboxEmails;
}}

How would i return the SMSRecieved to Inbox class to the GETSMS() method.

Suggestions please

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜