本文整理汇总了Java中com.sonyericsson.extras.liveware.extension.util.ExtensionUtils.getRegistrationVersion方法的典型用法代码示例。如果您正苦于以下问题:Java ExtensionUtils.getRegistrationVersion方法的具体用法?Java ExtensionUtils.getRegistrationVersion怎么用?Java ExtensionUtils.getRegistrationVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sonyericsson.extras.liveware.extension.util.ExtensionUtils
的用法示例。
在下文中一共展示了ExtensionUtils.getRegistrationVersion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerOrUpdateWidgetRegistration
import com.sonyericsson.extras.liveware.extension.util.ExtensionUtils; //导入方法依赖的package包/类
/**
* Register or update widget registration.
*
* @param apiRegistrationId The API registration ID.
* @param values The content values to register.
* @return True if the registration was successful.
*/
private boolean registerOrUpdateWidgetRegistration(long apiRegistrationId, ContentValues values) {
if (ExtensionUtils.getRegistrationVersion(mContext) < 3) {
// Widget registration only possible if Registration API version 3 or later.
return false;
}
values.put(Registration.WidgetRegistrationColumns.API_REGISTRATION_ID, apiRegistrationId);
long widgetRegistrationId = getWidgetRegistrationId(apiRegistrationId,
values.getAsString(Registration.WidgetRegistrationColumns.KEY));
if (widgetRegistrationId != ExtensionUtils.INVALID_ID) {
return mContext.getContentResolver().update(Registration.WidgetRegistration.URI,
values, Registration.WidgetRegistrationColumns._ID + " = ?", new String[] {
Long.toString(widgetRegistrationId)
}) > 0;
} else {
return mContext.getContentResolver()
.insert(Registration.WidgetRegistration.URI, values) != null;
}
}
示例2: getWidgetRegistrationId
import com.sonyericsson.extras.liveware.extension.util.ExtensionUtils; //导入方法依赖的package包/类
/**
* Get the widget registration id from a widget registration key.
*
* @param apiRegistrationId The API registration id.
* @param key The key.
* @return The widget registration id.
*/
private long getWidgetRegistrationId(long apiRegistrationId, String key) {
if (ExtensionUtils.getRegistrationVersion(mContext) < 3) {
// Widget registration only possible if Registration API version 3 or later.
return ExtensionUtils.INVALID_ID;
}
Cursor cursor = null;
try {
cursor = mContext.getContentResolver().query(
Registration.WidgetRegistration.URI,
new String[] {
Registration.WidgetRegistrationColumns._ID
}
,Registration.WidgetRegistrationColumns.API_REGISTRATION_ID + " = ? AND "
+ Registration.WidgetRegistrationColumns.KEY + " = ?", new String[] {
Long.toString(apiRegistrationId), key
}, null);
if (cursor != null && cursor.moveToFirst()) {
return cursor.getLong(cursor.getColumnIndexOrThrow(Registration.WidgetRegistrationColumns._ID));
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return ExtensionUtils.INVALID_ID;
}
示例3: getWidgetRegistrationKeys
import com.sonyericsson.extras.liveware.extension.util.ExtensionUtils; //导入方法依赖的package包/类
/**
* Get all widget registration keys for a specific API registration ID.
*
* @param apiRegistrationId The API registration id.
* @return A list with the keys.
*/
private List<String> getWidgetRegistrationKeys(long apiRegistrationId) {
List<String> keys = new ArrayList<String>();
if (ExtensionUtils.getRegistrationVersion(mContext) < 3) {
return keys;
}
Cursor cursor = null;
try {
cursor = mContext.getContentResolver().query(Registration.WidgetRegistration.URI,
new String[] {
Registration.WidgetRegistrationColumns.KEY
}, Registration.WidgetRegistrationColumns.API_REGISTRATION_ID + " = ?",
new String[] {
Long.toString(apiRegistrationId)
}, null);
while (cursor != null && cursor.moveToNext()) {
String key = cursor.getString(cursor
.getColumnIndex(Registration.WidgetRegistrationColumns.KEY));
keys.add(key);
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return keys;
}