欢迎来到天天文库
浏览记录
ID:41332311
大小:29.00 KB
页数:4页
时间:2019-08-22
《短信接收广播》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、短信接收广播1.定义信息接收广播publicclassMsgBroadcastReceiverextendsBroadcastReceiver{privatestaticfinalStringTAG="MsgBroadcastReceiver";StringSMS_RECEIVED="android.provider.Telephony.SMS_RECEIVED";@OverridepublicvoidonReceive(Contextcontext,Intentintent){//TODOAuto-genera
2、tedmethodstubLog.i(TAG,"=========onReceive()");if(intent.getAction().equals(SMS_RECEIVED)){Bundleb=intent.getExtras();if(b!=null){Object[]pdusMsg=(Object[])b.get("pdus");for(Objectpdus:pdusMsg){byte[]pdusmessage=(byte[])pdus;SmsMessagesms=SmsMessage.createFro
3、mPdu(pdusmessage);Stringmobile=sms.getOriginatingAddress();//发送短信的手机号码Stringcontent=sms.getMessageBody();//短信内容Datedate=newDate(sms.getTimestampMillis());SimpleDateFormatformat=newSimpleDateFormat("yyyy-MM-ddHH:mm:ss");Stringtime=format.format(date);//得到发送时间L
4、og.i(TAG,TAG+"-------msm---------");Log.i(TAG,TAG+"-->mobile:"+mobile);Log.i(TAG,TAG+"-->content:"+content);Log.i(TAG,TAG+"-->time:"+time);}}}}}5、1000">
5、1000">
此文档下载收益归作者所有