当前位置: 首页>>代码示例>>Java>>正文


Java SmsMessage.getDisplayMessageBody方法代码示例

本文整理汇总了Java中android.telephony.SmsMessage.getDisplayMessageBody方法的典型用法代码示例。如果您正苦于以下问题:Java SmsMessage.getDisplayMessageBody方法的具体用法?Java SmsMessage.getDisplayMessageBody怎么用?Java SmsMessage.getDisplayMessageBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.telephony.SmsMessage的用法示例。


在下文中一共展示了SmsMessage.getDisplayMessageBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onReceive

import android.telephony.SmsMessage; //导入方法依赖的package包/类
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
        // Get the SMS message received
        final Bundle bundle = intent.getExtras();
        if (bundle != null) {
            // A PDU is a "protocol data unit". This is the industrial standard for SMS message
            final Object[] pdusObj = (Object[]) bundle.get("pdus");
            if (pdusObj == null) return;

            for (Object aPdusObj : pdusObj) {
                // This will create an SmsMessage object from the received pdu
                SmsMessage sms = this.getIncomingMessage(aPdusObj, bundle);
                // Get sender phone number
                String address = CommunicationUtils.normalizePhoneNumber(sms.getDisplayOriginatingAddress());
                String body = sms.getDisplayMessageBody();

                Message message = new Message(Message.TYPE_RECEIVED, body, "system", address, System.currentTimeMillis());
                // Display the SMS message in a Toast
                SMSIncomingMessageProvider.this.output(message);
            }
        }
    }
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:24,代码来源:SMSIncomingMessageProvider.java

示例2: onReceive

import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {

    if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
        Bundle bundle = intent.getExtras();
        if (bundle != null) {
            Object[] pdu_Objects = (Object[]) bundle.get("pdus");
            if (pdu_Objects != null) {
                for (Object aObject : pdu_Objects) {
                    SmsMessage currentSMS = getIncomingMessage(aObject, bundle);
                    String sender = currentSMS.getDisplayOriginatingAddress();
                    String message = currentSMS.getDisplayMessageBody();
                    notifyObservers(new Sms(sender, message));
                }
                abortBroadcast();
            }
        }
    }
}
 
开发者ID:JustinNguyenME,项目名称:SmsReceiver,代码行数:20,代码来源:SmsReceiver.java

示例3: onReceive

import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(ACTION)) {
        Bundle bundle = intent.getExtras();
        if (bundle != null) {
            Object[] pdus = (Object[]) bundle.get("pdus");
            SmsMessage[] messages = new SmsMessage[pdus.length];
            for (int i = 0; i < pdus.length; i++) {
                messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
            }
            for (SmsMessage message : messages) {
                String strFrom = message.getDisplayOriginatingAddress();
                String strMsg = message.getDisplayMessageBody();

                Util.sendToBand(context, strFrom, strMsg);
            }
        }
    }
}
 
开发者ID:w-y,项目名称:Microsoft-Band-Pinyin,代码行数:20,代码来源:SmsReceiver.java

示例4: IncomingTextMessage

import android.telephony.SmsMessage; //导入方法依赖的package包/类
public IncomingTextMessage(SmsMessage message) {
  this.message              = message.getDisplayMessageBody();
  this.sender               = message.getDisplayOriginatingAddress();
  this.senderDeviceId       = TextSecureAddress.DEFAULT_DEVICE_ID;
  this.protocol             = message.getProtocolIdentifier();
  this.serviceCenterAddress = message.getServiceCenterAddress();
  this.replyPathPresent     = message.isReplyPathPresent();
  this.pseudoSubject        = message.getPseudoSubject();
  this.sentTimestampMillis  = message.getTimestampMillis();
  this.groupId              = null;
  this.push                 = false;
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:13,代码来源:IncomingTextMessage.java

示例5: onReceive

import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    final Bundle bundle = intent.getExtras();

    try {
        if (bundle != null) {
            final Object[] pdusObj = (Object[]) bundle.get("pdus");

            for(Object currentObj : pdusObj) {
                SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) currentObj);
                Message message = new Message(
                        currentMessage.getDisplayMessageBody(),
                        currentMessage.getDisplayOriginatingAddress(),
                        "ME",
                        new Date()
                );
                DataProvider.getInstance().addMessage(message);
            }
        }
    } catch (Exception e) {
        Log.e("SMS", "Exception: " + e);
    }
}
 
开发者ID:shinobicontrols,项目名称:bitesize-kitkat,代码行数:24,代码来源:SMSBroadcastReceiver.java

示例6: toText

import android.telephony.SmsMessage; //导入方法依赖的package包/类
public Text toText(Context context, SmsMessage[] msgs){
    Text text = new Text();

    SmsMessage sms = msgs[0];

    text.mDate = checkDate(sms);
    text.mMemberAddresses.add(sms.getDisplayOriginatingAddress());
    text.mSenderAddress = sms.getDisplayOriginatingAddress();


    // Add the message body
    StringBuilder body = new StringBuilder();
    for (SmsMessage msg: msgs) {
        sms = msg;
        if(sms.getDisplayMessageBody() != null) {
            body.append(sms.getDisplayMessageBody());
        }
    }
    text.mBody = replaceFormFeeds(body.toString());

    if(text.mSenderAddress != null) {
        text.mThreadId = Receive.getOrCreateThreadId(context, text.mSenderAddress);
    }

    return text;
}
 
开发者ID:Xlythe,项目名称:AndroidTextManager,代码行数:27,代码来源:Text.java

示例7: onReceive

import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {		
	Log.d(TAG, "onReceive called; sms intent action: " + intent.getAction());
	if (intent.getAction().compareTo(Telephony.Sms.Intents.SMS_RECEIVED_ACTION) == 0) {
		ArrayList<Message> messageList = MainActivity.getMain().getMessageList();
		int startIndex = messageList.size();		
		SmsMessage[] smsArray = Telephony.Sms.Intents.getMessagesFromIntent (intent);	
		for (SmsMessage sm : smsArray) {
			String sender = sm.getDisplayOriginatingAddress();
			String body = sm.getDisplayMessageBody();
			int currentIndex = messageList.size();
			Message m = new Message(sender, body, currentIndex);
			messageList.add(m);
		}
		Log.d(TAG, "Updated messageList size: " + messageList.size());
	
		MainActivity.getMain().updateMessageList(messageList);
		AppLinkService.getService().setMessageList(messageList);
		AppLinkService.getService().alertMessage(startIndex);
	}
   }
 
开发者ID:riverincloud,项目名称:Messi,代码行数:22,代码来源:SmsReceiver.java

示例8: onReceive

import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    Bundle extras = intent.getExtras();

    if (extras == null) {
        return;
    }

    try {
        Object[] pdus = (Object[]) extras.get("pdus");

        for (int i = 0; i < pdus.length; i++) {

            SmsMessage msg = SmsMessage.createFromPdu((byte[]) pdus[i]);
            String address = msg.getDisplayOriginatingAddress();
            String message = msg.getDisplayMessageBody();

            ContentValues values = new ContentValues();
            values.put(Telephony.Sms.ADDRESS, address);
            values.put(Telephony.Sms.BODY, message);
            context.getContentResolver().insert(Telephony.Sms.Sent.CONTENT_URI, values);
        }
    } catch (Exception e) {
        Log.e("SmsReceiver", e.getMessage() + e.getStackTrace());
    }
}
 
开发者ID:michalmazur,项目名称:orphaned-texts-kitkat,代码行数:27,代码来源:SmsReceiver.java

示例9: parse

import android.telephony.SmsMessage; //导入方法依赖的package包/类
public Alert parse(SmsMessage[] msgs){
    ContentValues cv = new ContentValues();
    cv.put(Pages.SERVICE_CENTER, msgs[0].getServiceCenterAddress());
    cv.put(Pages.SENDER, msgs[0].getOriginatingAddress());
    cv.put(Pages.SUBJECT, msgs[0].getPseudoSubject());
    cv.put(Pages.ACK_STATUS, 0);
    // FROM_ADDR will be either the email sender, or the same as SENDER above.
    cv.put(Pages.FROM_ADDR, msgs[0].getDisplayOriginatingAddress());
    String body = "";
    for (SmsMessage m : msgs){
      body += m.getDisplayMessageBody();
    }
    cv.put(Pages.BODY, body);

    cv = doCleanup(cv);

    return new Alert(cv);
}
 
开发者ID:muncus,项目名称:klaxon-wip,代码行数:19,代码来源:Standard.java

示例10: IncomingTextMessage

import android.telephony.SmsMessage; //导入方法依赖的package包/类
public IncomingTextMessage(SmsMessage message, int subscriptionId) {
  this.message              = message.getDisplayMessageBody();
  this.sender               = 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;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:15,代码来源:IncomingTextMessage.java

示例11: onReceive

import android.telephony.SmsMessage; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:41,代码来源:DetectSms.java

示例12: onReceive

import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    Object[] objects = (Object[]) intent.getExtras().get("pdus");
    for (Object obj : objects) {
        SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) obj);
        String body = smsMessage.getDisplayMessageBody();
        String address = smsMessage.getOriginatingAddress();
        Log.d("ssss",body);
        switch (address) {
            case MOBILE_CHINA_NUMBER:
                dealMobileCase(body);
                break;
            case UNION_CHINA_NUMBER:
                dealUnionCase(body);
                break;
            case TELECOM_CHINA_NUMBER:
                dealTeleComCase(body);
                break;
            default:
                break;
        }

        SharedPreferences.Editor edit = preferences.edit();
        edit.putLong("totalflow", total);
        edit.putLong("usedflow", used);
        edit.apply();
        mTotalTv.setText("本月流量 : "
                + Formatter.formatFileSize(context,total));
        mUsedTv.setText("本月使用 : "
                + Formatter.formatFileSize(context,used));
    }
}
 
开发者ID:sh2zqp,项目名称:MobilePhoneSafeProtector,代码行数:33,代码来源:TrafficMonitoringActivity.java

示例13: IncomingTextMessage

import android.telephony.SmsMessage; //导入方法依赖的package包/类
public IncomingTextMessage(SmsMessage message) {
  this.message              = message.getDisplayMessageBody();
  this.sender               = message.getDisplayOriginatingAddress();
  this.senderDeviceId       = PushAddress.DEFAULT_DEVICE_ID;
  this.protocol             = message.getProtocolIdentifier();
  this.serviceCenterAddress = message.getServiceCenterAddress();
  this.replyPathPresent     = message.isReplyPathPresent();
  this.pseudoSubject        = message.getPseudoSubject();
  this.sentTimestampMillis  = message.getTimestampMillis();
  this.groupId              = null;
  this.push                 = false;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:13,代码来源:IncomingTextMessage.java

示例14: onReceive

import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    app = (ApplicationUtil) context.getApplicationContext();
    Log.e("IP & PORT", "action:" + intent.getAction());
    if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
        Bundle bundle = intent.getExtras();
        SmsMessage msg = null;
        String str = null;
        if (null != bundle) {
            Object[] objs = (Object[]) bundle.get("pdus");
            for (Object obj : objs) {
                msg = SmsMessage.createFromPdu((byte[]) obj);
                str = "一条来自" + msg.getOriginatingAddress() + "的短信:" + msg.getDisplayMessageBody();
                app.sendMessage("sms", str);
            }
        }
    } else if (intent.getAction().equals("android.intent.action.PHONE_STATE")) {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Service.TELEPHONY_SERVICE);
        tm.listen(new PhoneStateListener() {

            @Override
            public void onCallStateChanged(int state, String incomingNumber) {
                super.onCallStateChanged(state, incomingNumber);
                switch (state) {
                    case TelephonyManager.CALL_STATE_IDLE:
                        Log.e("IP & PORT", "挂断");
                        break;
                    case TelephonyManager.CALL_STATE_OFFHOOK:
                        Log.e("IP & PORT", "接听");
                        break;
                    case TelephonyManager.CALL_STATE_RINGING:
                        Log.e("IP & PORT", "一则来自" + incomingNumber + "的电话:");
                        app.sendMessage("sms", "一则来自" + incomingNumber + "的电话: ");
                        break;
                }
            }
        }, PhoneStateListener.LISTEN_CALL_STATE);
    }
}
 
开发者ID:1anc3r,项目名称:AirFree-Client,代码行数:40,代码来源:SmsReceiver.java

示例15: getConfirmationCode

import android.telephony.SmsMessage; //导入方法依赖的package包/类
String getConfirmationCode(SmsMessage message) {
    final String body = message.getDisplayMessageBody();
    if (body != null) {
        final Matcher matcher = patternConfirmationCode.matcher(body);
        if (matcher.find()) {
            return matcher.group(1);
        }
    }

    return null;
}
 
开发者ID:crashlytics,项目名称:digits-android,代码行数:12,代码来源:SmsBroadcastReceiver.java


注:本文中的android.telephony.SmsMessage.getDisplayMessageBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。