- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在做一些 android/CM9 学习,并试图从其中一个库存应用程序中分离出一些功能,以便:
在这种情况下,我正在学习使用联系人的最近通话 list 。我正在尝试使用字段 Calls.COUNTRY_ISO
,与股票应用程序相同,但 Eclipse 坚持“COUNTRY_ISO 无法解析或不是字段”。我知道这一点是因为它通过 @hide 属性从 SDK 中隐藏起来,因此也知道该字段确实存在。
我的字符串数组的声明:
import android.provider.CallLog.Calls
public static final String[] _PROJECTION = new String[] {
Calls._ID, // 0
Calls.NUMBER, // 1
Calls.DATE, // 2
Calls.DURATION, // 3
Calls.TYPE, // 4
Calls.COUNTRY_ISO, // 5
Calls.VOICEMAIL_URI, // 6
Calls.GEOCODED_LOCATION, // 7
Calls.CACHED_NAME, // 8
Calls.CACHED_NUMBER_TYPE, // 9
Calls.CACHED_NUMBER_LABEL, // 10
Calls.CACHED_LOOKUP_URI, // 11
Calls.CACHED_MATCHED_NUMBER, // 12
Calls.CACHED_NORMALIZED_NUMBER, // 13
Calls.CACHED_PHOTO_ID, // 14
Calls.CACHED_FORMATTED_NUMBER, // 15
Calls.IS_READ, // 16
};
是否可以强制 Eclipse 忽略此错误(最好仅在此数组上)并继续编译?
完整类是文件 CallLog.java 中的 android.provider.calllog.Calls
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.provider;
import com.android.internal.telephony.CallerInfo;
import com.android.internal.telephony.Connection;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.DataUsageFeedback;
import android.text.TextUtils;
/**
* The CallLog provider contains information about placed and received calls.
*/
public class CallLog {
public static final String AUTHORITY = "call_log";
/**
* The content:// style URL for this provider
*/
public static final Uri CONTENT_URI =
Uri.parse("content://" + AUTHORITY);
/**
* Contains the recent calls.
*/
public static class Calls implements BaseColumns {
/**
* The content:// style URL for this table
*/
public static final Uri CONTENT_URI =
Uri.parse("content://call_log/calls");
/**
* The content:// style URL for filtering this table on phone numbers
*/
public static final Uri CONTENT_FILTER_URI =
Uri.parse("content://call_log/calls/filter");
/**
* An optional URI parameter which instructs the provider to allow the operation to be
* applied to voicemail records as well.
* <p>
* TYPE: Boolean
* <p>
* Using this parameter with a value of {@code true} will result in a security error if the
* calling package does not have appropriate permissions to access voicemails.
*
* @hide
*/
public static final String ALLOW_VOICEMAILS_PARAM_KEY = "allow_voicemails";
/**
* Content uri with {@link #ALLOW_VOICEMAILS_PARAM_KEY} set. This can directly be used to
* access call log entries that includes voicemail records.
*
* @hide
*/
public static final Uri CONTENT_URI_WITH_VOICEMAIL = CONTENT_URI.buildUpon()
.appendQueryParameter(ALLOW_VOICEMAILS_PARAM_KEY, "true")
.build();
/**
* The default sort order for this table
*/
public static final String DEFAULT_SORT_ORDER = "date DESC";
/**
* The MIME type of {@link #CONTENT_URI} and {@link #CONTENT_FILTER_URI}
* providing a directory of calls.
*/
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/calls";
/**
* The MIME type of a {@link #CONTENT_URI} sub-directory of a single
* call.
*/
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/calls";
/**
* The type of the call (incoming, outgoing or missed).
* <P>Type: INTEGER (int)</P>
*/
public static final String TYPE = "type";
/** Call log type for incoming calls. */
public static final int INCOMING_TYPE = 1;
/** Call log type for outgoing calls. */
public static final int OUTGOING_TYPE = 2;
/** Call log type for missed calls. */
public static final int MISSED_TYPE = 3;
/**
* Call log type for voicemails.
* @hide
*/
public static final int VOICEMAIL_TYPE = 4;
/**
* The phone number as the user entered it.
* <P>Type: TEXT</P>
*/
public static final String NUMBER = "number";
/**
* The ISO 3166-1 two letters country code of the country where the
* user received or made the call. (HIDDEN)
* <P>
* Type: TEXT
* </P>
*
* @hide
*/
public static final String COUNTRY_ISO = "countryiso";
/**
* The date the call occured, in milliseconds since the epoch
* <P>Type: INTEGER (long)</P>
*/
public static final String DATE = "date";
/**
* The duration of the call in seconds
* <P>Type: INTEGER (long)</P>
*/
public static final String DURATION = "duration";
/**
* Whether or not the call has been acknowledged
* <P>Type: INTEGER (boolean)</P>
*/
public static final String NEW = "new";
/**
* The cached name associated with the phone number, if it exists.
* This value is not guaranteed to be current, if the contact information
* associated with this number has changed.
* <P>Type: TEXT</P>
*/
public static final String CACHED_NAME = "name";
/**
* The cached number type (Home, Work, etc) associated with the
* phone number, if it exists.
* This value is not guaranteed to be current, if the contact information
* associated with this number has changed.
* <P>Type: INTEGER</P>
*/
public static final String CACHED_NUMBER_TYPE = "numbertype";
/**
* The cached number label, for a custom number type, associated with the
* phone number, if it exists.
* This value is not guaranteed to be current, if the contact information
* associated with this number has changed.
* <P>Type: TEXT</P>
*/
public static final String CACHED_NUMBER_LABEL = "numberlabel";
/**
* URI of the voicemail entry. Populated only for {@link #VOICEMAIL_TYPE} (HIDDEN).
* <P>Type: TEXT</P>
* @hide
*/
public static final String VOICEMAIL_URI = "voicemail_uri";
/**
* Whether this item has been read or otherwise consumed by the user.
* <p>
* Unlike the {@link #NEW} field, which requires the user to have acknowledged the
* existence of the entry, this implies the user has interacted with the entry.
* <P>Type: INTEGER (boolean)</P>
*/
public static final String IS_READ = "is_read";
/**
* A geocoded location for the number associated with this call.
* <p>
* The string represents a city, state, or country associated with the number. (HIDDEN)
* <P>Type: TEXT</P>
* @hide
*/
public static final String GEOCODED_LOCATION = "geocoded_location";
/**
* The cached URI to look up the contact associated with the phone number, if it exists.
* This value is not guaranteed to be current, if the contact information
* associated with this number has changed. (HIDDEN)
* <P>Type: TEXT</P>
* @hide
*/
public static final String CACHED_LOOKUP_URI = "lookup_uri";
/**
* The cached phone number of the contact which matches this entry, if it exists.
* This value is not guaranteed to be current, if the contact information
* associated with this number has changed. (HIDDEN)
* <P>Type: TEXT</P>
* @hide
*/
public static final String CACHED_MATCHED_NUMBER = "matched_number";
/**
* The cached normalized version of the phone number, if it exists.
* This value is not guaranteed to be current, if the contact information
* associated with this number has changed. (HIDDEN)
* <P>Type: TEXT</P>
* @hide
*/
public static final String CACHED_NORMALIZED_NUMBER = "normalized_number";
/**
* The cached photo id of the picture associated with the phone number, if it exists.
* This value is not guaranteed to be current, if the contact information
* associated with this number has changed. (HIDDEN)
* <P>Type: INTEGER (long)</P>
* @hide
*/
public static final String CACHED_PHOTO_ID = "photo_id";
/**
* The cached formatted phone number.
* This value is not guaranteed to be present. (HIDDEN)
* <P>Type: TEXT</P>
* @hide
*/
public static final String CACHED_FORMATTED_NUMBER = "formatted_number";
/**
* Adds a call to the call log.
*
* @param ci the CallerInfo object to get the target contact from. Can be null
* if the contact is unknown.
* @param context the context used to get the ContentResolver
* @param number the phone number to be added to the calls db
* @param presentation the number presenting rules set by the network for
* "allowed", "payphone", "restricted" or "unknown"
* @param callType enumerated values for "incoming", "outgoing", or "missed"
* @param start time stamp for the call in milliseconds
* @param duration call duration in seconds
*
* {@hide}
*/
public static Uri addCall(CallerInfo ci, Context context, String number,
int presentation, int callType, long start, int duration) {
final ContentResolver resolver = context.getContentResolver();
// If this is a private number then set the number to Private, otherwise check
// if the number field is empty and set the number to Unavailable
if (presentation == Connection.PRESENTATION_RESTRICTED) {
number = CallerInfo.PRIVATE_NUMBER;
if (ci != null) ci.name = "";
} else if (presentation == Connection.PRESENTATION_PAYPHONE) {
number = CallerInfo.PAYPHONE_NUMBER;
if (ci != null) ci.name = "";
} else if (TextUtils.isEmpty(number)
|| presentation == Connection.PRESENTATION_UNKNOWN) {
number = CallerInfo.UNKNOWN_NUMBER;
if (ci != null) ci.name = "";
}
ContentValues values = new ContentValues(5);
values.put(NUMBER, number);
values.put(TYPE, Integer.valueOf(callType));
values.put(DATE, Long.valueOf(start));
values.put(DURATION, Long.valueOf(duration));
values.put(NEW, Integer.valueOf(1));
if (callType == MISSED_TYPE) {
values.put(IS_READ, Integer.valueOf(0));
}
if (ci != null) {
values.put(CACHED_NAME, ci.name);
values.put(CACHED_NUMBER_TYPE, ci.numberType);
values.put(CACHED_NUMBER_LABEL, ci.numberLabel);
}
if ((ci != null) && (ci.person_id > 0)) {
// Update usage information for the number associated with the contact ID.
// We need to use both the number and the ID for obtaining a data ID since other
// contacts may have the same number.
final Cursor cursor;
// We should prefer normalized one (probably coming from
// Phone.NORMALIZED_NUMBER column) first. If it isn't available try others.
if (ci.normalizedNumber != null) {
final String normalizedPhoneNumber = ci.normalizedNumber;
cursor = resolver.query(Phone.CONTENT_URI,
new String[] { Phone._ID },
Phone.CONTACT_ID + " =? AND " + Phone.NORMALIZED_NUMBER + " =?",
new String[] { String.valueOf(ci.person_id), normalizedPhoneNumber},
null);
} else {
final String phoneNumber = ci.phoneNumber != null ? ci.phoneNumber : number;
cursor = resolver.query(Phone.CONTENT_URI,
new String[] { Phone._ID },
Phone.CONTACT_ID + " =? AND " + Phone.NUMBER + " =?",
new String[] { String.valueOf(ci.person_id), phoneNumber},
null);
}
if (cursor != null) {
try {
if (cursor.getCount() > 0 && cursor.moveToFirst()) {
final Uri feedbackUri = DataUsageFeedback.FEEDBACK_URI.buildUpon()
.appendPath(cursor.getString(0))
.appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
DataUsageFeedback.USAGE_TYPE_CALL)
.build();
resolver.update(feedbackUri, new ContentValues(), null, null);
}
} finally {
cursor.close();
}
}
}
Uri result = resolver.insert(CONTENT_URI, values);
removeExpiredEntries(context);
return result;
}
/**
* Query the call log database for the last dialed number.
* @param context Used to get the content resolver.
* @return The last phone number dialed (outgoing) or an empty
* string if none exist yet.
*/
public static String getLastOutgoingCall(Context context) {
final ContentResolver resolver = context.getContentResolver();
Cursor c = null;
try {
c = resolver.query(
CONTENT_URI,
new String[] {NUMBER},
TYPE + " = " + OUTGOING_TYPE,
null,
DEFAULT_SORT_ORDER + " LIMIT 1");
if (c == null || !c.moveToFirst()) {
return "";
}
return c.getString(0);
} finally {
if (c != null) c.close();
}
}
private static void removeExpiredEntries(Context context) {
final ContentResolver resolver = context.getContentResolver();
resolver.delete(CONTENT_URI, "_id IN " +
"(SELECT _id FROM calls ORDER BY " + DEFAULT_SORT_ORDER
+ " LIMIT -1 OFFSET 500)", null);
}
}
}
最佳答案
标有@hide 注释的字段似乎是受限制的,类似于普通Java 运行时中的sun.*
包。尝试访问这些值通常被认为是一个坏主意。为什么需要访问它们?
关于java - 强制 eclipse 忽略 "COUNTRY_ISO cannot be resolved or is not a field' 错误并编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13584081/
我使用 resolver() 作为 socket() 的替代方法,因为我发现当多个连接建立到不同的 IP 时,它最终会停止工作。 无论如何它会向我返回一个警告,我应该使用 dns.resolver.R
我有这个代码: var promise1 = new Promise(function(resolve, reject) { setTimeout(() => { console
我仍在学习 PHP,我认为我不是母语人士,这并不难理解。 此时,看了一大堆文档,跳入了深水区,于是打开Laravel源文件,一个接一个地看,试图更好地理解MVC的整个实现,包括路由、中间件如何组合成一
public JsonResult GetEvents(double start, double end) { var userName = Session["UserName"] as st
我正在使用 bluebird,我看到了两种将同步函数解析为 Promise 的方法,但我不明白这两种方法之间的区别。看起来堆栈跟踪有点不同,所以它们不仅仅是一个别名,对吧? 那么首选的方式是什么? 方
我写了下面的代码: function readFile(path) { return new Promise(function(resolve, reject){ if(!fs
我正在使用 bluebird,我看到了两种将同步函数解析为 Promise 的方法,但我不明白这两种方法之间的区别。看起来堆栈跟踪有点不同,所以它们不仅仅是一个别名,对吧? 那么首选的方式是什么? 方
在某处读过这个例子: return new Promise( (resolve, reject) => { fs.readFile(file, (err, data) => { if (e
我刚开始学习 React,我一直在尝试让我的 React 应用程序连接到我的数据库 var mysql = require('mysql'); var con = mysql.createConnec
我需要从 $http 调用中返回一个 promise 中的自定义响应,以便我可以链接更多调用。我有两个可用的实现。有人可以解释两者之间的区别,并争论其中一个更好吗? 在 fooService.js 实
免责声明:这里实际上提出了两个问题,但我觉得它们密切相关。 我正在尝试将 promise 对象传递给指令,并且我想在 promise 解析后立即在指令中运行一些初始化代码。 在我的 Controlle
我正在尝试创建类似于 this code 的东西在 boost.asio 示例中找到。 套接字.h: class some_class { private: ... boost
正如我们所知,Promise 构造函数采用一个执行函数,该函数具有两个参数,我们使用它们来生成成功案例或失败案例。今天我在编程,我被卡住了,但后来我解决了这个问题,但我发现了一件事需要理解。 有什么区
我认为 Promise.resolve 和 new Promise(resolve) 可以互换。 考虑一下: A. new RSVP.Promise(function (resolve, reject
我下载了一个 Java 项目,我想研究并从中学习一些东西。当我在另一台计算机上下载它时效果很好,但是当我在我的计算机上尝试时,几乎每个声明和导入都会给出错误消息“* cannot be resolve
我昨天看到了一些有趣的编译器行为,我想我明白为什么会这样,但我想确定一下。所以,我不会写我的推理,只写事实。 请注意,我使用 vector 而不是 string 并不是错字。我是故意这样做的,这样编译
我正在尝试运行 Ember 测试,它给出了这个错误,提示无法找到从 `AppName/resolver 导入的模块 ember-resolver。 我不确定是什么原因造成的。我正在使用 Ember-c
Code#1 和 Code#2 的区别在于:Code#1 使用 resolve(p) 而 Code#2 使用 p.then(()=>resolve()) 。我希望输出序列是不变的,但它们会生成不同的序
IntelliJ IDEA 无法解析内置 JVM 类型和方法的常见原因有哪些?例如,当我将鼠标悬停在 String 上时,工具提示显示“无法解析符号“String””。就好像 IntelliJ 不知道
IntelliJ IDEA 无法解析内置 JVM 类型和方法的常见原因有哪些?例如,当我将鼠标悬停在 String 上时,工具提示显示“无法解析符号“String””。就好像 IntelliJ 不知道
我是一名优秀的程序员,十分优秀!