本文整理汇总了Java中android.provider.Telephony.Sms类的典型用法代码示例。如果您正苦于以下问题:Java Sms类的具体用法?Java Sms怎么用?Java Sms使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sms类属于android.provider.Telephony包,在下文中一共展示了Sms类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getSMSAppPackageName
import android.provider.Telephony.Sms; //导入依赖的package包/类
@TargetApi(19)
public static String getSMSAppPackageName(Context context) {
if (VERSION.SDK_INT >= 19) {
return Sms.getDefaultSmsPackage(context);
}
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.DEFAULT");
intent.setType("vnd.android-dir/mms-sms");
ComponentName componentName = intent.resolveActivity(context.getPackageManager());
if (componentName != null) {
return componentName.getPackageName();
}
return null;
}
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:15,代码来源:AppIds.java
示例2: addMessageToUri
import android.provider.Telephony.Sms; //导入依赖的package包/类
/**
* Add an SMS to the given URI with the specified thread ID.
*
* @param resolver the content resolver to use
* @param uri the URI to add the message to
* @param address the address of the sender
* @param body the body of the message
* @param subject the pseudo-subject of the message
* @param date the timestamp for the message
* @param read true if the message has been read, false if not
* @param deliveryReport true if a delivery report was requested, false if not
* @param threadId the thread_id of the message
* @return the URI for the new message
* @hide
*/
public static Uri addMessageToUri(ContentResolver resolver,
Uri uri, String address, String body, String subject,
Long date, boolean read, boolean deliveryReport, long threadId) {
ContentValues values = new ContentValues(7);
values.put(Sms.ADDRESS, address);
if (date != null) {
values.put(Sms.DATE, date);
}
values.put(Sms.READ, read ? Integer.valueOf(1) : Integer.valueOf(0));
values.put(Sms.SUBJECT, subject);
values.put(Sms.BODY, body);
if (deliveryReport) {
values.put(Sms.STATUS, Sms.STATUS_PENDING);
}
if (threadId != -1L) {
values.put(Sms.THREAD_ID, threadId);
}
return resolver.insert(uri, values);
}
开发者ID:moezbhatti,项目名称:qksms,代码行数:36,代码来源:SmsHelper.java
示例3: dumpSmsTable
import android.provider.Telephony.Sms; //导入依赖的package包/类
public static void dumpSmsTable(Context context) {
LogTag.debug("**** Dump of sms table ****");
Cursor c = context.getContentResolver().query(Sms.CONTENT_URI,
SMS_PROJECTION, null, null, "_id DESC");
try {
// Only dump the latest 20 messages
c.moveToPosition(-1);
while (c.moveToNext() && c.getPosition() < 20) {
String body = c.getString(COLUMN_SMS_BODY);
LogTag.debug("dumpSmsTable " + BaseColumns._ID + ": " + c.getLong(COLUMN_ID) +
" " + Sms.THREAD_ID + " : " + c.getLong(DATE) +
" " + Sms.ADDRESS + " : " + c.getString(COLUMN_SMS_ADDRESS) +
" " + Sms.BODY + " : " + body.substring(0, Math.min(body.length(), 8)) +
" " + Sms.DATE + " : " + c.getLong(COLUMN_SMS_DATE) +
" " + Sms.TYPE + " : " + c.getInt(COLUMN_SMS_TYPE));
}
} finally {
c.close();
}
}
开发者ID:moezbhatti,项目名称:qksms,代码行数:21,代码来源:Conversation.java
示例4: lockMessage
import android.provider.Telephony.Sms; //导入依赖的package包/类
public static void lockMessage(Context context, MessageItem msgItem, boolean locked) {
Uri uri;
if ("sms".equals(msgItem.mType)) {
uri = Sms.CONTENT_URI;
} else {
uri = Mms.CONTENT_URI;
}
final Uri lockUri = ContentUris.withAppendedId(uri, msgItem.mMsgId);
final ContentValues values = new ContentValues(1);
values.put("locked", locked ? 1 : 0);
new Thread(() -> {
context.getContentResolver().update(lockUri,
values, null, null);
}, "MainActivity.lockMessage").start();
}
开发者ID:moezbhatti,项目名称:qksms,代码行数:18,代码来源:MessageUtils.java
示例5: getSmsThreadId
import android.provider.Telephony.Sms; //导入依赖的package包/类
/**
* Get the thread ID of the SMS message with the given URI
* @param context The context
* @param uri The URI of the SMS message
* @return The thread ID, or THREAD_NONE if the URI contains no entries
*/
public static long getSmsThreadId(Context context, Uri uri) {
Cursor cursor = SqliteWrapper.query(
context,
context.getContentResolver(),
uri,
SMS_THREAD_ID_PROJECTION,
null,
null,
null);
if (cursor == null) {
return THREAD_NONE;
}
try {
if (cursor.moveToFirst()) {
return cursor.getLong(cursor.getColumnIndex(Sms.THREAD_ID));
} else {
return THREAD_NONE;
}
} finally {
cursor.close();
}
}
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:31,代码来源:MessagingNotification.java
示例6: moveOutboxMessagesToFailedBox
import android.provider.Telephony.Sms; //导入依赖的package包/类
/**
* Move all messages that are in the outbox to the failed state and set them to unread.
* @return The number of messages that were actually moved
*/
private int moveOutboxMessagesToFailedBox() {
ContentValues values = new ContentValues(3);
values.put(Sms.TYPE, Sms.MESSAGE_TYPE_FAILED);
values.put(Sms.ERROR_CODE, SmsManager.RESULT_ERROR_GENERIC_FAILURE);
values.put(Sms.READ, Integer.valueOf(0));
int messageCount = SqliteWrapper.update(
getApplicationContext(), getContentResolver(), Outbox.CONTENT_URI,
values, "type = " + Sms.MESSAGE_TYPE_OUTBOX, null);
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE) || LogTag.DEBUG_SEND) {
Log.v(TAG, "moveOutboxMessagesToFailedBox messageCount: " + messageCount);
}
return messageCount;
}
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:20,代码来源:SmsReceiverService.java
示例7: onHandleIntent
import android.provider.Telephony.Sms; //导入依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
// This method is called on a worker thread.
Uri messageUri = intent.getData();
byte[] pdu = intent.getByteArrayExtra("pdu");
String format = intent.getStringExtra("format");
SmsMessage message = updateMessageStatus(this, messageUri, pdu, format);
// Called on a background thread, so it's OK to block.
if (message != null && message.getStatus() < Sms.STATUS_PENDING) {
MessagingNotification.blockingUpdateNewMessageIndicator(this,
MessagingNotification.THREAD_NONE, message.isStatusReportMessage());
}
}
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:17,代码来源:MessageStatusService.java
示例8: dumpSmsTable
import android.provider.Telephony.Sms; //导入依赖的package包/类
public static void dumpSmsTable(Context context) {
LogTag.debug("**** Dump of sms table ****");
Cursor c = context.getContentResolver().query(Sms.CONTENT_URI,
SMS_PROJECTION, null, null, "_id DESC");
try {
// Only dump the latest 20 messages
c.moveToPosition(-1);
while (c.moveToNext() && c.getPosition() < 20) {
String body = c.getString(COLUMN_SMS_BODY);
LogTag.debug("dumpSmsTable " + BaseColumns._ID + ": "
+ c.getLong(COLUMN_ID) + " " + Sms.THREAD_ID + " : "
+ c.getLong(DATE) + " " + Sms.ADDRESS + " : "
+ c.getString(COLUMN_SMS_ADDRESS) + " " + Sms.BODY
+ " : " + body.substring(0, Math.min(body.length(), 8))
+ " " + Sms.DATE + " : " + c.getLong(COLUMN_SMS_DATE)
+ " " + Sms.TYPE + " : " + c.getInt(COLUMN_SMS_TYPE));
}
} finally {
c.close();
}
}
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:22,代码来源:Conversation.java
示例9: updateDraftSmsMessage
import android.provider.Telephony.Sms; //导入依赖的package包/类
private void updateDraftSmsMessage(final Conversation conv, String contents) {
final long threadId = conv.getThreadId();
if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
LogTag.debug("updateDraftSmsMessage tid=%d, contents=\"%s\"",
threadId, contents);
}
// If we don't have a valid thread, there's nothing to do.
if (threadId <= 0) {
return;
}
ContentValues values = new ContentValues(3);
values.put(Sms.THREAD_ID, threadId);
values.put(Sms.BODY, contents);
values.put(Sms.TYPE, Sms.MESSAGE_TYPE_DRAFT);
SqliteWrapper.insert(mActivity, mContentResolver, Sms.CONTENT_URI,
values);
asyncDeleteDraftMmsMessage(conv);
mMessageUri = null;
}
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:22,代码来源:WorkingMessage.java
示例10: lockMessage
import android.provider.Telephony.Sms; //导入依赖的package包/类
private void lockMessage(MessageItem msgItem, boolean locked) {
Uri uri;
if ("sms".equals(msgItem.mType)) {
uri = Sms.CONTENT_URI;
} else {
uri = Mms.CONTENT_URI;
}
final Uri lockUri = ContentUris.withAppendedId(uri, msgItem.mMsgId);
final ContentValues values = new ContentValues(1);
values.put("locked", locked ? 1 : 0);
new Thread(new Runnable() {
@Override
public void run() {
getContentResolver().update(lockUri, values, null, null);
}
}, "ComposeMessageActivity.lockMessage").start();
}
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:20,代码来源:ComposeMessageActivity.java
示例11: checkIfDefault
import android.provider.Telephony.Sms; //导入依赖的package包/类
@TargetApi(19)
public void checkIfDefault() {
final String myPackageName = getPackageName();
if (android.os.Build.VERSION.SDK_INT >= 19) {
if (!Telephony.Sms.getDefaultSmsPackage(this).equals(myPackageName)) {
// App is not default.
// Show the "not currently set as the default SMS app" dialog
System.out.println(" setting false");
isDefault = false;
Intent intent = new Intent(Sms.Intents.ACTION_CHANGE_DEFAULT);
intent.putExtra(Sms.Intents.EXTRA_PACKAGE_NAME,
getApplicationContext().getPackageName());
startActivityForResult(intent,99);
}
else{
System.out.println(" setting true");
isDefault = true;
}
}
else
isDefault = true;
}
开发者ID:saurabh2590,项目名称:EasyAccess,代码行数:24,代码来源:TextMessagesApp.java
示例12: updateDraftSmsMessage
import android.provider.Telephony.Sms; //导入依赖的package包/类
private void updateDraftSmsMessage(final Conversation conv, String contents) {
final long threadId = conv.getThreadId();
if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
LogTag.debug("updateDraftSmsMessage tid=%d, contents=\"%s\"", threadId, contents);
}
// If we don't have a valid thread, there's nothing to do.
if (threadId <= 0) {
return;
}
ContentValues values = new ContentValues(3);
values.put(Sms.THREAD_ID, threadId);
values.put(Sms.BODY, contents);
values.put(Sms.TYPE, Sms.MESSAGE_TYPE_DRAFT);
SqliteWrapper.insert(mActivity, mContentResolver, Sms.CONTENT_URI, values);
asyncDeleteDraftMmsMessage(conv);
mMessageUri = null;
}
开发者ID:slvn,项目名称:android-aosp-mms,代码行数:20,代码来源:WorkingMessage.java
示例13: editSmsMessageItem
import android.provider.Telephony.Sms; //导入依赖的package包/类
private void editSmsMessageItem(MessageItem msgItem) {
// When the message being edited is the only message in the conversation, the delete
// below does something subtle. The trigger "delete_obsolete_threads_pdu" sees that a
// thread contains no messages and silently deletes the thread. Meanwhile, the mConversation
// object still holds onto the old thread_id and code thinks there's a backing thread in
// the DB when it really has been deleted. Here we try and notice that situation and
// clear out the thread_id. Later on, when Conversation.ensureThreadId() is called, we'll
// create a new thread if necessary.
synchronized(mConversation) {
if (mConversation.getMessageCount() <= 1) {
mConversation.clearThreadId();
MessagingNotification.setCurrentlyDisplayedThreadId(
MessagingNotification.THREAD_NONE);
}
}
// Delete the old undelivered SMS and load its content.
Uri uri = ContentUris.withAppendedId(Sms.CONTENT_URI, msgItem.mMsgId);
SqliteWrapper.delete(ComposeMessageActivity.this,
mContentResolver, uri, null, null);
mWorkingMessage.setText(msgItem.mBody);
}
开发者ID:slvn,项目名称:android-aosp-mms,代码行数:23,代码来源:ComposeMessageActivity.java
示例14: lockMessage
import android.provider.Telephony.Sms; //导入依赖的package包/类
private void lockMessage(MessageItem msgItem, boolean locked) {
Uri uri;
if ("sms".equals(msgItem.mType)) {
uri = Sms.CONTENT_URI;
} else {
uri = Mms.CONTENT_URI;
}
final Uri lockUri = ContentUris.withAppendedId(uri, msgItem.mMsgId);
final ContentValues values = new ContentValues(1);
values.put("locked", locked ? 1 : 0);
new Thread(new Runnable() {
@Override
public void run() {
getContentResolver().update(lockUri,
values, null, null);
}
}, "ComposeMessageActivity.lockMessage").start();
}
开发者ID:slvn,项目名称:android-aosp-mms,代码行数:21,代码来源:ComposeMessageActivity.java
示例15: copyToPhoneMemory
import android.provider.Telephony.Sms; //导入依赖的package包/类
private void copyToPhoneMemory(Cursor cursor) {
String address = cursor.getString(
cursor.getColumnIndexOrThrow("address"));
String body = cursor.getString(cursor.getColumnIndexOrThrow("body"));
Long date = cursor.getLong(cursor.getColumnIndexOrThrow("date"));
try {
if (isIncomingMessage(cursor)) {
Sms.Inbox.addMessage(mContentResolver, address, body, null, date, true /* read */);
} else {
Sms.Sent.addMessage(mContentResolver, address, body, null, date);
}
} catch (SQLiteException e) {
SqliteWrapper.checkSQLiteException(this, e);
}
}
开发者ID:slvn,项目名称:android-aosp-mms,代码行数:17,代码来源:ManageSimMessages.java
示例16: blockingMarkAllSmsMessagesAsSeen
import android.provider.Telephony.Sms; //导入依赖的package包/类
private static void blockingMarkAllSmsMessagesAsSeen(final Context context) {
ContentResolver resolver = context.getContentResolver();
Cursor cursor = resolver.query(Sms.Inbox.CONTENT_URI,
SEEN_PROJECTION,
"seen=0",
null,
null);
int count = 0;
if (cursor != null) {
try {
count = cursor.getCount();
} finally {
cursor.close();
}
}
if (count == 0) {
return;
}
if (DELETEDEBUG || Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
Log.d(TAG, "mark " + count + " SMS msgs as seen");
}
ContentValues values = new ContentValues(1);
values.put("seen", 1);
resolver.update(Sms.Inbox.CONTENT_URI,
values,
"seen=0",
null);
}
开发者ID:moezbhatti,项目名称:qksms,代码行数:35,代码来源:Conversation.java
示例17: isMe
import android.provider.Telephony.Sms; //导入依赖的package包/类
public boolean isMe() {
// Logic matches MessageListAdapter.getItemViewType which is used to decide which
// type of MessageListItem to create: a left or right justified item depending on whether
// the message is incoming or outgoing.
boolean isIncomingMms = isMms()
&& (mBoxId == Mms.MESSAGE_BOX_INBOX
|| mBoxId == Mms.MESSAGE_BOX_ALL);
boolean isIncomingSms = isSms()
&& (mBoxId == Sms.MESSAGE_TYPE_INBOX
|| mBoxId == Sms.MESSAGE_TYPE_ALL);
return !(isIncomingMms || isIncomingSms);
}
开发者ID:moezbhatti,项目名称:qksms,代码行数:13,代码来源:MessageItem.java
示例18: isOutgoingMessage
import android.provider.Telephony.Sms; //导入依赖的package包/类
public boolean isOutgoingMessage() {
boolean isOutgoingMms = isMms() && (mBoxId == Mms.MESSAGE_BOX_OUTBOX);
boolean isOutgoingSms = isSms()
&& ((mBoxId == Sms.MESSAGE_TYPE_FAILED)
|| (mBoxId == Sms.MESSAGE_TYPE_OUTBOX)
|| (mBoxId == Sms.MESSAGE_TYPE_QUEUED));
return isOutgoingMms || isOutgoingSms;
}
开发者ID:moezbhatti,项目名称:qksms,代码行数:9,代码来源:MessageItem.java
示例19: isFailedMessage
import android.provider.Telephony.Sms; //导入依赖的package包/类
public boolean isFailedMessage() {
boolean isFailedMms = isMms()
&& (mErrorType >= MmsSms.ERR_TYPE_GENERIC_PERMANENT);
boolean isFailedSms = isSms()
&& (mBoxId == Sms.MESSAGE_TYPE_FAILED);
return isFailedMms || isFailedSms;
}
开发者ID:moezbhatti,项目名称:qksms,代码行数:8,代码来源:MessageItem.java
示例20: getSmsReportItems
import android.provider.Telephony.Sms; //导入依赖的package包/类
private List<DeliveryReportItem> getSmsReportItems() {
String selection = "_id = " + mMessageId;
Cursor c = SqliteWrapper.query(mContext, mContext.getContentResolver(), Sms.CONTENT_URI,
SMS_REPORT_STATUS_PROJECTION, selection, null, null);
if (c == null) {
return null;
}
try {
if (c.getCount() <= 0) {
return null;
}
List<DeliveryReportItem> items = new ArrayList<>();
while (c.moveToNext()) {
// For sent messages with delivery reports, we stick the delivery time in the
// date_sent column (see MessageStatusReceiver).
String deliveryDateString = null;
long deliveryDate = c.getLong(COLUMN_DATE_SENT);
int messageType = c.getInt(COLUMN_MESSAGE_TYPE);
if (messageType == Sms.MESSAGE_TYPE_SENT && deliveryDate > 0) {
deliveryDateString = mContext.getString(R.string.delivered_label) +
MessageUtils.formatTimeStampString(mContext, deliveryDate, true);
}
items.add(new DeliveryReportItem(
mContext.getString(R.string.recipient_label) + c.getString(COLUMN_RECIPIENT),
mContext.getString(R.string.status_label) +
getSmsStatusText(c.getInt(COLUMN_DELIVERY_STATUS)),
deliveryDateString));
}
return items;
} finally {
c.close();
}
}
开发者ID:moezbhatti,项目名称:qksms,代码行数:37,代码来源:DeliveryReportHelper.java
注:本文中的android.provider.Telephony.Sms类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论