Java Code Examples for android.telephony.SmsMessage#getServiceCenterAddress()
The following examples show how to use
android.telephony.SmsMessage#getServiceCenterAddress() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IncomingTextMessage.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
public IncomingTextMessage(@NonNull RecipientId sender, @NonNull SmsMessage message, int subscriptionId) { this.message = message.getDisplayMessageBody(); this.sender = sender; this.senderDeviceId = SignalServiceAddress.DEFAULT_DEVICE_ID; this.protocol = message.getProtocolIdentifier(); this.serviceCenterAddress = message.getServiceCenterAddress(); this.replyPathPresent = message.isReplyPathPresent(); this.pseudoSubject = message.getPseudoSubject(); this.sentTimestampMillis = message.getTimestampMillis(); this.serverTimestampMillis = -1; this.subscriptionId = subscriptionId; this.expiresInMillis = 0; this.groupId = null; this.push = false; this.unidentified = false; }
Example 2
Source File: IncomingTextMessage.java From bcm-android with GNU General Public License v3.0 | 6 votes |
public IncomingTextMessage(@NonNull AccountContext accountContext, @NonNull SmsMessage message, int subscriptionId) { this.message = message.getDisplayMessageBody(); this.payloadType = parseBodyPayloadType(this.message); this.sender = Address.from(accountContext, message.getDisplayOriginatingAddress()); this.senderDeviceId = SignalServiceAddress.DEFAULT_DEVICE_ID; this.protocol = message.getProtocolIdentifier(); this.serviceCenterAddress = message.getServiceCenterAddress(); this.replyPathPresent = message.isReplyPathPresent(); this.pseudoSubject = message.getPseudoSubject(); this.sentTimestampMillis = message.getTimestampMillis(); this.subscriptionId = subscriptionId; this.expiresInMillis = 0; this.groupId = null; this.push = false; }
Example 3
Source File: SmsReceiver.java From DevUtils with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { try { Object[] pdus = (Object[]) intent.getExtras().get("pdus"); String originatingAddress = null; String serviceCenterAddress = null; if (pdus != null) { // 消息内容 String message = ""; // 循环拼接内容 for (Object object : pdus) { SmsMessage sms = SmsMessage.createFromPdu((byte[]) object); message += sms.getMessageBody(); // 消息内容 - 多条消息, 合并成一条 originatingAddress = sms.getOriginatingAddress(); serviceCenterAddress = sms.getServiceCenterAddress(); // 触发事件 if (sListener != null) { sListener.onMessage(sms); } } // 触发事件 if (sListener != null) { sListener.onMessage(message, originatingAddress, serviceCenterAddress); } } } catch (Exception e) { LogPrintUtils.eTag(TAG, e, "onReceive"); } }
Example 4
Source File: DetectSms.java From XERUNG with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { // Retrieves a map of extended data from the intent. final Bundle bundle = intent.getExtras(); try { if (bundle != null) { final Object[] pdusObj = (Object[]) bundle.get("pdus"); for (int i = 0; i < pdusObj.length; i++) { SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]); String phoneNumber = currentMessage.getDisplayOriginatingAddress(); String sendername = currentMessage.getOriginatingAddress(); Log.d(TAG, "sendername is " + sendername); String servicecntradd = currentMessage.getServiceCenterAddress(); Log.d(TAG, "servicecenteraddress is : " + servicecntradd); String senderNum = phoneNumber; Log.d(TAG, "Displayoriginationg address is : " + sendername); String message = currentMessage.getDisplayMessageBody(); Log.d(TAG, "senderNum: " + senderNum + "; message: " + message); if (senderNum.equalsIgnoreCase("IM-MEDICO")||senderNum.equalsIgnoreCase("AD-MEDICO")||senderNum.equalsIgnoreCase("DM-MEDICO")||senderNum.equalsIgnoreCase("AM-MEDICO")) { if (!message.isEmpty()) { Pattern intsOnly = Pattern.compile("\\d{5}"); Matcher makeMatch = intsOnly.matcher(message); makeMatch.find(); OTPcode = makeMatch.group(); Intent intentNew = new Intent(); intentNew.setAction("SMS_RECEIVED"); intentNew.putExtra("otp_code", OTPcode); context.sendBroadcast(intentNew); System.out.println(OTPcode); } } else { //Toast.makeText(context, "didn't identified the number", Toast.LENGTH_LONG).show(); } }// end for loop } // bundle is null } catch (Exception e) { Log.e("SmsReceiver", "Exception smsReceiver" + e); } }
Example 5
Source File: DetectSms.java From XERUNG with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { // Retrieves a map of extended data from the intent. final Bundle bundle = intent.getExtras(); try { if (bundle != null) { final Object[] pdusObj = (Object[]) bundle.get("pdus"); for (int i = 0; i < pdusObj.length; i++) { SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]); String phoneNumber = currentMessage.getDisplayOriginatingAddress(); String sendername = currentMessage.getOriginatingAddress(); Log.d(TAG, "sendername is " + sendername); String servicecntradd = currentMessage.getServiceCenterAddress(); Log.d(TAG, "servicecenteraddress is : " + servicecntradd); String senderNum = phoneNumber; Log.d(TAG, "Displayoriginationg address is : " + sendername); String message = currentMessage.getDisplayMessageBody(); Log.d(TAG, "senderNum: " + senderNum + "; message: " + message); if (senderNum.equalsIgnoreCase("IM-MEDICO")||senderNum.equalsIgnoreCase("AD-MEDICO")||senderNum.equalsIgnoreCase("DM-MEDICO")||senderNum.equalsIgnoreCase("AM-MEDICO")) { if (!message.isEmpty()) { Pattern intsOnly = Pattern.compile("\\d{5}"); Matcher makeMatch = intsOnly.matcher(message); makeMatch.find(); OTPcode = makeMatch.group(); Intent intentNew = new Intent(); intentNew.setAction("SMS_RECEIVED"); intentNew.putExtra("otp_code", OTPcode); context.sendBroadcast(intentNew); System.out.println(OTPcode); } } else { //Toast.makeText(context, "didn't identified the number", Toast.LENGTH_LONG).show(); } }// end for loop } // bundle is null } catch (Exception e) { Log.e("SmsReceiver", "Exception smsReceiver" + e); } }
Example 6
Source File: IncomingTextMessage.java From Silence with GNU General Public License v3.0 | 5 votes |
public IncomingTextMessage(SmsMessage message, int subscriptionId, boolean receivedWhenLocked) { this.message = message.getDisplayMessageBody(); this.sender = message.getDisplayOriginatingAddress(); this.senderDeviceId = 1; this.protocol = message.getProtocolIdentifier(); this.serviceCenterAddress = message.getServiceCenterAddress(); this.replyPathPresent = message.isReplyPathPresent(); this.pseudoSubject = message.getPseudoSubject(); this.sentTimestampMillis = message.getTimestampMillis(); this.subscriptionId = subscriptionId; this.groupId = null; this.push = false; this.receivedWhenLocked = receivedWhenLocked; }
Example 7
Source File: SmsReceiver.java From AndroidBase with Apache License 2.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { try { if (LogUtils.getLogConfig().isEnable()) { LogUtils.i("收到广播:" + intent.getAction()); Bundle bundle = intent.getExtras(); for (String key : bundle.keySet()) { LogUtils.i( key + " : " + bundle.get(key)); } } Object[] pdus = (Object[]) intent.getExtras().get("pdus"); String fromAddress = null; String serviceCenterAddress = null; if (pdus != null) { String msgBody = ""; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT) { for (Object obj : pdus) { SmsMessage sms = SmsMessage.createFromPdu((byte[]) obj); msgBody += sms.getMessageBody(); fromAddress = sms.getOriginatingAddress(); serviceCenterAddress = sms.getServiceCenterAddress(); if (smsListener != null) { smsListener.onMessage(sms); } //Log.i(TAG, "getDisplayMessageBody:" + sms.getDisplayMessageBody()); //Log.i(TAG, "getDisplayOriginatingAddress:" + sms.getDisplayOriginatingAddress()); //Log.i(TAG, "getEmailBody:" + sms.getEmailBody()); //Log.i(TAG, "getEmailFrom:" + sms.getEmailFrom()); //Log.i(TAG, "getMessageBody:" + sms.getMessageBody()); //Log.i(TAG, "getOriginatingAddress:" + sms.getOriginatingAddress()); //Log.i(TAG, "getPseudoSubject:" + sms.getPseudoSubject()); //Log.i(TAG, "getServiceCenterAddress:" + sms.getServiceCenterAddress()); //Log.i(TAG, "getIndexOnIcc:" + sms.getIndexOnIcc()); //Log.i(TAG, "getMessageClass:" + sms.getMessageClass()); //Log.i(TAG, "getUserData:" + new String(sms.getUserData())); } } if (smsListener != null) { smsListener.onMessage(msgBody, fromAddress, serviceCenterAddress); } } } catch (Exception e) { e.printStackTrace(); } }
Example 8
Source File: SmsReceiver.java From zone-sdk with MIT License | 4 votes |
@Override public void onReceive(Context context, Intent intent) { try { if (LogZSDK.INSTANCE.levelOK(LogLevel.i)) { LogZSDK.INSTANCE.i( "收到广播:" + intent.getAction()); Bundle bundle = intent.getExtras(); for (String key : bundle.keySet()) { LogZSDK.INSTANCE.i( key + " : " + bundle.get(key)); } } Object[] pdus = (Object[]) intent.getExtras().get("pdus"); String fromAddress = null; String serviceCenterAddress = null; if (pdus != null) { String msgBody = ""; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT) { for (Object obj : pdus) { SmsMessage sms = SmsMessage.createFromPdu((byte[]) obj); msgBody += sms.getMessageBody(); fromAddress = sms.getOriginatingAddress(); serviceCenterAddress = sms.getServiceCenterAddress(); if (smsListener != null) { smsListener.onMessage(sms); } //Log.i(TAG, "getDisplayMessageBody:" + sms.getDisplayMessageBody()); //Log.i(TAG, "getDisplayOriginatingAddress:" + sms.getDisplayOriginatingAddress()); //Log.i(TAG, "getEmailBody:" + sms.getEmailBody()); //Log.i(TAG, "getEmailFrom:" + sms.getEmailFrom()); //Log.i(TAG, "getMessageBody:" + sms.getMessageBody()); //Log.i(TAG, "getOriginatingAddress:" + sms.getOriginatingAddress()); //Log.i(TAG, "getPseudoSubject:" + sms.getPseudoSubject()); //Log.i(TAG, "getServiceCenterAddress:" + sms.getServiceCenterAddress()); //Log.i(TAG, "getIndexOnIcc:" + sms.getIndexOnIcc()); //Log.i(TAG, "getMessageClass:" + sms.getMessageClass()); //Log.i(TAG, "getUserData:" + new String(sms.getUserData())); } } if (smsListener != null) { smsListener.onMessage(msgBody, fromAddress, serviceCenterAddress); } } } catch (Exception e) { e.printStackTrace(); } }
Example 9
Source File: SmsReceiver.java From android-common with Apache License 2.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { try { if (Log.isPrint) { Log.i(TAG, "收到广播:" + intent.getAction()); Bundle bundle = intent.getExtras(); for (String key : bundle.keySet()) { Log.i(TAG, key + " : " + bundle.get(key)); } } Object[] pdus = (Object[]) intent.getExtras().get("pdus"); String fromAddress = null; String serviceCenterAddress = null; if (pdus != null) { String msgBody = ""; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT) { for (Object obj : pdus) { SmsMessage sms = SmsMessage.createFromPdu((byte[]) obj); msgBody += sms.getMessageBody(); fromAddress = sms.getOriginatingAddress(); serviceCenterAddress = sms.getServiceCenterAddress(); if (smsListener != null) { smsListener.onMessage(sms); } //Log.i(TAG, "getDisplayMessageBody:" + sms.getDisplayMessageBody()); //Log.i(TAG, "getDisplayOriginatingAddress:" + sms.getDisplayOriginatingAddress()); //Log.i(TAG, "getEmailBody:" + sms.getEmailBody()); //Log.i(TAG, "getEmailFrom:" + sms.getEmailFrom()); //Log.i(TAG, "getMessageBody:" + sms.getMessageBody()); //Log.i(TAG, "getOriginatingAddress:" + sms.getOriginatingAddress()); //Log.i(TAG, "getPseudoSubject:" + sms.getPseudoSubject()); //Log.i(TAG, "getServiceCenterAddress:" + sms.getServiceCenterAddress()); //Log.i(TAG, "getIndexOnIcc:" + sms.getIndexOnIcc()); //Log.i(TAG, "getMessageClass:" + sms.getMessageClass()); //Log.i(TAG, "getUserData:" + new String(sms.getUserData())); } } if (smsListener != null) { smsListener.onMessage(msgBody, fromAddress, serviceCenterAddress); } } } catch (Exception e) { e.printStackTrace(); } }