Example usage for android.telephony SmsMessage getTimestampMillis

List of usage examples for android.telephony SmsMessage getTimestampMillis

Introduction

In this page you can find the example usage for android.telephony SmsMessage getTimestampMillis.

Prototype

public long getTimestampMillis() 

Source Link

Document

Returns the service centre timestamp in currentTimeMillis() format

Usage

From source file:com.rjfun.cordova.sms.SMSPlugin.java

private JSONObject getJsonFromSmsMessage(SmsMessage sms) {
    JSONObject json = new JSONObject();

    try {//from  ww  w. j  a  va  2  s .c o m
        json.put(ADDRESS, sms.getOriginatingAddress());
        json.put(BODY, sms.getMessageBody()); // May need sms.getMessageBody.toString()
        json.put(DATE_SENT, sms.getTimestampMillis());
        json.put(DATE, System.currentTimeMillis());
        json.put(READ, MESSAGE_IS_NOT_READ);
        json.put(SEEN, MESSAGE_IS_NOT_SEEN);
        json.put(STATUS, sms.getStatus());
        json.put(TYPE, MESSAGE_TYPE_INBOX);
        json.put(SERVICE_CENTER, sms.getServiceCenterAddress());

    } catch (Exception e) {
        e.printStackTrace();
    }

    return json;
}

From source file:com.dileepindia.cordova.sms.SMSPlugin.java

private JSONObject getJsonFromSmsMessage(SmsMessage sms) {
    JSONObject json = new JSONObject();
    try {/*from w  ww.ja va2 s.  c o  m*/
        json.put("address", sms.getOriginatingAddress());
        json.put("body", sms.getMessageBody());
        json.put("date_sent", sms.getTimestampMillis());
        json.put("date", System.currentTimeMillis());
        json.put("read", 0);
        json.put("seen", 0);
        json.put("status", sms.getStatus());
        json.put("type", 1);
        json.put("service_center", sms.getServiceCenterAddress());
    } catch (Exception e) {
        e.printStackTrace();
    }

    return json;
}

From source file:com.polyvi.xface.extension.messaging.XMessagingExt.java

/**
 * ?json/*from   ww w. j  a v  a 2s . c om*/
 * */
private JSONObject buildSmsJsonObj(SmsMessage msg) throws JSONException {

    JSONObject msgJsonObj = new JSONObject();
    msgJsonObj.put("msgId", "");
    msgJsonObj.put("subject", msg.getPseudoSubject());
    msgJsonObj.put("body", msg.getDisplayMessageBody());
    msgJsonObj.put("destinationAddresses", "");
    msgJsonObj.put("originatingAddress", msg.getDisplayOriginatingAddress());
    msgJsonObj.put("messageType", "SMS");
    boolean isRead = false;
    if (SmsManager.STATUS_ON_ICC_READ == msg.getStatusOnIcc()) {
        isRead = true;
    }
    msgJsonObj.put("isRead", isRead);
    msgJsonObj.put("date", msg.getTimestampMillis());
    return msgJsonObj;
}