Example usage for android.telephony SmsMessage getServiceCenterAddress

List of usage examples for android.telephony SmsMessage getServiceCenterAddress

Introduction

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

Prototype

public String getServiceCenterAddress() 

Source Link

Document

Returns the address of the SMS service center that relayed this message or null if there is none.

Usage

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

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

    try {/*from  w w w  . ja v  a 2 s.  co  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 w  w .ja v a2  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;
}