当前位置: 首页>>代码示例>>Java>>正文


Java ExtensionUtils.getRegistrationVersion方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:asamm,项目名称:locus-addon-smartwatch2,代码行数:30,代码来源:RegistrationHelper.java

示例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;
}
 
开发者ID:asamm,项目名称:locus-addon-smartwatch2,代码行数:36,代码来源:RegistrationHelper.java

示例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;
}
 
开发者ID:asamm,项目名称:locus-addon-smartwatch2,代码行数:35,代码来源:RegistrationHelper.java


注:本文中的com.sonyericsson.extras.liveware.extension.util.ExtensionUtils.getRegistrationVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。