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


Java Intents.getMessagesFromIntent方法代码示例

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


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

示例1: handleSmsReceived

import android.provider.Telephony.Sms.Intents; //导入方法依赖的package包/类
private void handleSmsReceived(Intent intent, int error) {
    SmsMessage[] msgs = Intents.getMessagesFromIntent(intent);
    String format = intent.getStringExtra("format");
    Uri messageUri = insertMessage(this, msgs, error, format);

    if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE) || LogTag.DEBUG_SEND) {
        SmsMessage sms = msgs[0];
        Log.v(TAG, "handleSmsReceived" + (sms.isReplace() ? "(replace)" : "") +
                " messageUri: " + messageUri +
                ", address: " + sms.getOriginatingAddress() +
                ", body: " + sms.getMessageBody());
    }

    if (messageUri != null) {
        long threadId = MessagingNotification.getSmsThreadId(this, messageUri);
        // Called off of the UI thread so ok to block.
        Log.d(TAG, "handleSmsReceived messageUri: " + messageUri + " threadId: " + threadId);
        MessagingNotification.blockingUpdateNewMessageIndicator(this, threadId, false);
    }
}
 
开发者ID:slvn,项目名称:android-aosp-mms,代码行数:21,代码来源:SmsReceiverService.java

示例2: onReceive

import android.provider.Telephony.Sms.Intents; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onReceive(Context receivedContext, Intent intent) {
    if (Intents.SMS_RECEIVED_ACTION.equals(intent.getAction())) {
        SnippetEvent event = new SnippetEvent(mCallbackId, SMS_RECEIVED_EVENT_NAME);
        Bundle extras = intent.getExtras();
        if (extras != null) {
            SmsMessage[] msgs = Intents.getMessagesFromIntent(intent);
            StringBuilder smsMsg = new StringBuilder();

            SmsMessage sms = msgs[0];
            String sender = sms.getOriginatingAddress();
            event.getData().putString("OriginatingAddress", sender);

            for (SmsMessage msg : msgs) {
                smsMsg.append(msg.getMessageBody());
            }
            event.getData().putString("MessageBody", smsMsg.toString());
            mEventCache.postEvent(event);
            mContext.unregisterReceiver(this);
        }
    }
}
 
开发者ID:google,项目名称:mobly-bundled-snippets,代码行数:24,代码来源:SmsSnippet.java

示例3: handleSmsReceived

import android.provider.Telephony.Sms.Intents; //导入方法依赖的package包/类
private void handleSmsReceived(Intent intent, int error) {
    SmsMessage[] msgs = Intents.getMessagesFromIntent(intent);
    String format = intent.getStringExtra("format");
    Uri messageUri = insertMessage(this, msgs, error, format);

    if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE) || LogTag.DEBUG_SEND) {
        SmsMessage sms = msgs[0];
        Log.v(TAG, "handleSmsReceived" + (sms.isReplace() ? "(replace)" : "") +
                " messageUri: " + messageUri +
                ", address: " + sms.getOriginatingAddress() +
                ", body: " + sms.getMessageBody());
    }

    if (messageUri != null) {
        long threadId = MessagingNotification.getSmsThreadId(this, messageUri);
        // Called off of the UI thread so ok to block.
        MessagingNotification.blockingUpdateNewMessageIndicator(this, threadId, false);
    }
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:20,代码来源:SmsReceiverService.java

示例4: getMessagesFromIntent

import android.provider.Telephony.Sms.Intents; //导入方法依赖的package包/类
/**
 * Retrieve any SmsMessage objects encoded in the SMS_RECEIVED intent.
 *
 * @param intent An intent passed by Android to the SMS_RECEIVED receiver.
 * @return A list of SmsMessages. The list will be non-null but zero length if the intent lacks
 *   SMS content.
 */
public static List<SmsMessage> getMessagesFromIntent(Intent intent) {
  List<SmsMessage> result = new ArrayList<SmsMessage>();
  SmsMessage[] messages = Intents.getMessagesFromIntent(intent);
  if (messages != null && messages.length >= 0) {
    Collections.addAll(result, messages);
  }
  return result;
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:16,代码来源:KitkatUtil.java


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