本文整理汇总了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);
}