本文整理汇总了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);
}
}
示例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);
}
}
}
示例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);
}
}
示例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;
}