发送短信时,我截取了短信的pdu。想请教下:1、pdu里面有发送时间信息吗?2、若现在我想将这条短信存入UIM卡上,且pdu中没有发送时间的话,发送时间如何确定呢?

解决方案 »

  1.   

    Bundle bundle = intent.getExtras();
    Object[] objs = (Object[])bundle.get("pdus");
    //Here SmsMessage :not my self defined
    SmsMessage[] smses = new SmsMessage[objs.length];
    for(int i=0;i<smses.length;i++)
    {
    SmsMessage mes = SmsMessage.createFromPdu((byte[])(objs[i]));
    String body = mes.getDisplayMessageBody();
    String address = mes.getDisplayOriginatingAddress();
    long date = mes.getTimestampMillis();
    int protocol = mes.getProtocolIdentifier();
    //如果想要得到更多信息,可以监听数据库,通过改变去得到
     );
     
      }
    如果你想要得到一个String类型的时间的话,可以用SimpleDateFormat去转换一下