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


Java PebbleAppType类代码示例

本文整理汇总了Java中com.getpebble.android.kit.Constants.PebbleAppType的典型用法代码示例。如果您正苦于以下问题:Java PebbleAppType类的具体用法?Java PebbleAppType怎么用?Java PebbleAppType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PebbleAppType类属于com.getpebble.android.kit.Constants包,在下文中一共展示了PebbleAppType类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: customizeWatchApp

import com.getpebble.android.kit.Constants.PebbleAppType; //导入依赖的package包/类
/**
 * Send a message to the connected Pebble to "customize" a built-in PebbleKit watch-app. This is intended to allow
 * third-party Android applications to apply custom branding (both name & icon) on the watch without needing to
 * distribute a complete watch-app.
 *
 * @param context
 *         The context used to send the broadcast. (Protip: pass in the ApplicationContext here.)
 * @param appType
 *         The watch-app to be configured. Options are either
 * @param name
 *         The custom name to be applied to the watch-app. Names must be less than 32 characters in length.
 * @param icon
 *         The custom icon to be applied to the watch-app. Icons must be black-and-white bitmaps no larger than 32px
 *         in either dimension.
 *
 * @throws IllegalArgumentException
 *         Thrown if the specified name or icon are invalid. {@link PebbleAppType#SPORTS} or {@link
 *         PebbleAppType#GOLF}.
 */
public static void customizeWatchApp(final Context context, final PebbleAppType appType,
                                     final String name, final Bitmap icon) throws IllegalArgumentException {

    if (appType == null) {
        throw new IllegalArgumentException("app type cannot be null");
    }

    if (name.length() > NAME_MAX_LENGTH) {
        throw new IllegalArgumentException(String.format(
                "app name exceeds maximum length (%d)", NAME_MAX_LENGTH));
    }

    if (icon.getHeight() > ICON_MAX_DIMENSIONS || icon.getWidth() > ICON_MAX_DIMENSIONS) {
        throw new IllegalArgumentException(String.format(
                "app icon exceeds maximum dimensions (32px x 32px); got (%dpx x %dpx)",
                icon.getWidth(), icon.getHeight()));
    }

    final Intent customizeAppIntent = new Intent(INTENT_APP_CUSTOMIZE);
    customizeAppIntent.putExtra(CUST_APP_TYPE, appType.ord);
    customizeAppIntent.putExtra(CUST_NAME, name);
    customizeAppIntent.putExtra(CUST_ICON, icon);
    context.sendBroadcast(customizeAppIntent);
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:44,代码来源:PebbleKit.java


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