我正在 Eclipse 中构建一个 Android 应用程序。
在一个类方法中,有以下代码:
threadId = Threads.getOrCreateThreadId(mContext, recipients);
mContext 是一个上下文,接收者是 Set <string>
Eclipse 在该行中显示错误:
方法 getOrCreateThreadId(Context, Set<String>) 未定义 Telephony.Threads 类型
在文件 Telephony.java 中,有定义此方法的 Threads 类:
/**
* Helper functions for the "threads" table used by MMS and SMS.
*/
public static final class Threads implements ThreadsColumns {
private static final String[] ID_PROJECTION = { BaseColumns._ID };
private static final String STANDARD_ENCODING = "UTF-8";
private static final Uri THREAD_ID_CONTENT_URI = Uri.parse(
"content://mms-sms/threadID");
public static final Uri CONTENT_URI = Uri.withAppendedPath(
MmsSms.CONTENT_URI, "conversations");
public static final Uri OBSOLETE_THREADS_URI = Uri.withAppendedPath(
CONTENT_URI, "obsolete");
public static final int COMMON_THREAD = 0;
public static final int BROADCAST_THREAD = 1;
// No one should construct an instance of this class.
private Threads() {
}
/**
* This is a single-recipient version of
* getOrCreateThreadId. It's convenient for use with SMS
* messages.
*/
public static long getOrCreateThreadId(Context context, String recipient) {
Set<String> recipients = new HashSet<String>();
recipients.add(recipient);
return getOrCreateThreadId(context, recipients);
}
/**
* Given the recipients list and subject of an unsaved message,
* return its thread ID. If the message starts a new thread,
* allocate a new thread ID. Otherwise, use the appropriate
* existing thread ID.
*
* Find the thread ID of the same set of recipients (in
* any order, without any additions). If one
* is found, return it. Otherwise, return a unique thread ID.
*/
public static long getOrCreateThreadId(
Context context, Set<String> recipients) {
Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
for (String recipient : recipients) {
if (Mms.isEmailAddress(recipient)) {
recipient = Mms.extractAddrSpec(recipient);
}
uriBuilder.appendQueryParameter("recipient", recipient);
}
Uri uri = uriBuilder.build();
Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
uri, ID_PROJECTION, null, null, null);
if (cursor != null) {
try {
if (cursor.moveToFirst()) {
return cursor.getLong(0);
}
} finally {
cursor.close();
}
}
throw new IllegalArgumentException("Unable to find or allocate a thread ID.");
}
}
为什么它没有找到方法并告诉我它是未定义的?
谢谢!