Sony Addon SDK public class

ExtensionUtils

This project is no longer being supported and will not get any further updates.
extends java.lang.Object
  1. java.lang.Object
  2. com.sonyericsson.extras.liveware.extension.util.ExtensionUtils

Class Overview

The extension utils class contains utility functions used by several extensions.

Summary

Constants
int INVALID_ID Invalid id
Public Constructors
ExtensionUtils()
Public Methods
static void drawText(Canvas canvas, java.lang.String text, float x, float y, TextPaint textPaint, int availableWidth)

Draw text on canvas.

static java.lang.String getUriString(Context context, int resourceId)

Get URI string from resourceId.

static boolean areAnyAccessoriesConnected(Context context)

Check in the database if there are any accessories connected.

static java.lang.String getContactName(Context context, Uri contactUri)

Get the contact name from a URI.

static Bitmap getContactPhoto(Context context, Uri contactUri)

Get the contact photo from a contact URI.

static Bitmap getBitmapFromUri(Context context, java.lang.String uriString)

Get bitmap from a URI.

static long getExtensionId(Context context)

Get id of a registered extension

static long getRegistrationId(Context context, java.lang.String hostAppPackageName, long extensionId)

Get id of a registered extension

static boolean supportsHistory(Intent intent)

Get the value of the intent extra parameter EXTRA_ACCESSORY_SUPPORTS_HISTORY from the intent that started the configuration activity.

static boolean supportsActions(Intent intent)

Get the value of the intent extra parameter EXTRA_ACCESSORY_SUPPORTS_ACTIONS from the intent that started the configuration activity.

static java.lang.String getFormattedTime(long publishedTime)

Get formatted time.

static int getRegistrationVersion(Context context)

Get the version of the registration API that is implemented by the current phone/tablet the extension is running on.

static boolean hasIsEmulatedColumnInDisplayTable(Context context)

Check if the IS_EMULATED column is present in the Registration.Display table in the registration API.

Constants

public static final int INVALID_ID

Invalid id

Constant Value: -1 (0xffffffffffffffff)

Public Constructors

public ExtensionUtils()

Public Methods

public static void drawText(Canvas canvas, java.lang.String text, float x, float y, TextPaint textPaint, int availableWidth)

Draw text on canvas. Shade if text too long to fit.

Parameters
canvas The canvas to draw in.
text The text to draw.
x The x coordinate.
y The y coordinate.
textPaint The paint to draw with.
availableWidth The available width for the text

public static java.lang.String getUriString(Context context, int resourceId)

Get URI string from resourceId.

Parameters
context The context.
resourceId The resource id.
Returns

The URI string.

public static boolean areAnyAccessoriesConnected(Context context)

Check in the database if there are any accessories connected.

Parameters
context The context
Returns

True if at least one accessories is connected.

public static java.lang.String getContactName(Context context, Uri contactUri)

Get the contact name from a URI.

Parameters
context The context.
contactUri The contact URI.
Returns

The contact name.

public static Bitmap getContactPhoto(Context context, Uri contactUri)

Get the contact photo from a contact URI.

Parameters
context The context.
contactUri The contact URI.
Returns

The contact photo.

public static Bitmap getBitmapFromUri(Context context, java.lang.String uriString)

Get bitmap from a URI.

Parameters
context The context.
uriString The URI as a string.
Returns

The bitmap.

public static long getExtensionId(Context context)

Get id of a registered extension

Parameters
context
Returns

Id, INVALID_ID if extension is not registered

public static long getRegistrationId(Context context, java.lang.String hostAppPackageName, long extensionId)

Get id of a registered extension

Parameters
context
hostAppPackageName
extensionId
Returns

Id, INVALID_ID if extension is not registered

public static boolean supportsHistory(Intent intent)

Get the value of the intent extra parameter EXTRA_ACCESSORY_SUPPORTS_HISTORY from the intent that started the configuration activity.

Parameters
intent The intent that started the configuration activity, see CONFIGURATION_ACTIVITY
Returns

Value of EXTRA_ACCESSORY_SUPPORTS_HISTORY, true if not contained in the intent extras.

public static boolean supportsActions(Intent intent)

Get the value of the intent extra parameter EXTRA_ACCESSORY_SUPPORTS_ACTIONS from the intent that started the configuration activity.

Parameters
intent The intent that started the configuration activity, see CONFIGURATION_ACTIVITY
Returns

Value of EXTRA_ACCESSORY_SUPPORTS_ACTIONS, true if not contained in the intent extras.

public static java.lang.String getFormattedTime(long publishedTime)

Get formatted time.

Parameters
publishedTime The published time in millis.
Returns

The formatted time.

public static int getRegistrationVersion(Context context)

Get the version of the registration API that is implemented by the current phone/tablet the extension is running on.

Parameters
context The context.
Returns

The version of the registration API.

public static boolean hasIsEmulatedColumnInDisplayTable(Context context)

Check if the IS_EMULATED column is present in the Registration.Display table in the registration API.

Parameters
context The context.
Returns

True if the table exists.