Android Sony:SampleNotificationExtension:示例应用程序引发异常
我正在尝试向Sony LiveWare设备发送通知 我已安装:com.sonyericsson.extras.liveware.extension.notificationsample,但我在尝试运行它时遇到错误和异常:Android Sony:SampleNotificationExtension:示例应用程序引发异常,android,sony,sony-smartwatch,Android,Sony,Sony Smartwatch,我正在尝试向Sony LiveWare设备发送通知 我已安装:com.sonyericsson.extras.liveware.extension.notificationsample,但我在尝试运行它时遇到错误和异常: 将首选项活动加载到设备上 选中首选项屏幕上的“活动” 在SampleExtensionService中调用以下方法: private void addData() { Random rand = new Random(); int index = rand.ne
private void addData() {
Random rand = new Random();
int index = rand.nextInt(5);
String name = NAMES[index];
String message = MESSAGE[index];
long time = System.currentTimeMillis();
long sourceId = NotificationUtil
.getSourceId(this, EXTENSION_SPECIFIC_ID);
if (sourceId == NotificationUtil.INVALID_ID) {
Log.e(LOG_TAG, "Failed to insert data");
return;
}
String profileImage = ExtensionUtils.getUriString(this,
R.drawable.widget_default_userpic_bg);
ContentValues eventValues = new ContentValues();
eventValues.put(Notification.EventColumns.EVENT_READ_STATUS, false);
eventValues.put(Notification.EventColumns.DISPLAY_NAME, name);
eventValues.put(Notification.EventColumns.MESSAGE, message);
eventValues.put(Notification.EventColumns.PERSONAL, 1);
eventValues.put(Notification.EventColumns.PROFILE_IMAGE_URI, profileImage);
eventValues.put(Notification.EventColumns.PUBLISHED_TIME, time);
eventValues.put(Notification.EventColumns.SOURCE_ID, sourceId);
try {
getContentResolver().insert(Notification.Event.URI, eventValues);
} catch (IllegalArgumentException e) {
Log.e(LOG_TAG, "Failed to insert event", e);
} catch (SecurityException e) {
Log.e(LOG_TAG, "Failed to insert event, is Live Ware Manager installed?", e);
} catch (SQLException e) {
Log.e(LOG_TAG, "Failed to insert event", e);
}
}
第一个问题是“long sourceId=NotificationUtil.getSourceId(这个扩展名是特定的)”返回-1
我不知道如何更改,但文档说这是一个可选字段。因此,我将其移除,以查看是否可以进一步:
删除sourceId代码时,插入调用出现异常:
“java.lang.SecurityException:您没有足够的权限执行插入”
我的环境:
HTC One V搭配LiveView腕式寻呼机
我已经安装了以下应用程序
实时取景
SmartConnect(LiveWare管理器)
如果有人知道为LiveWare提供简单文本通知的更直接的方法,我将非常感谢您对本示例的帮助
编辑:
取得了一些进展。在此处找到模拟器:
android sdk\add-ons\addon-sony\u add-on\u sdk\u 1\u 0-sony-16\apk\u文件
我把它安装在电话上了。“SampleExtensionService”在模拟器中运行良好
我现在的假设是,加载项示例与LiveView设备不兼容。不幸的是,SmartExtension API不支持LiveView。相反,LiveView有一个特定的开发工具包
如果您将来想从Sony Mobile购买更新的可穿戴设备,则基于智能扩展API的通知扩展将可用于多个设备,包括SmartWatch、SmartWatch 2、SBH50、SBH52等。遗憾的是,SmartExtension API不支持LiveView。相反,LiveView有一个特定的开发工具包
如果您将来想从索尼移动公司购买更新的可穿戴设备,基于智能扩展API的通知扩展将可用于包括SmartWatch、SmartWatch 2、SBH50、SBH52等在内的多个设备。LiveView是否算作SmartWatch?我将其标记为SmartWatch,因为我没有足够的“点数”将其标记为LiveWare。据我所知,索尼智能手表和LiveView寻呼机都使用LiveWare。我曾设想,如果我能向LiveView设备发送通知,该设备也将适用于索尼智能手表。无论如何,该示例不适用于LiveView设备。LiveView是否算作SmartWatch?我将其标记为SmartWatch,因为我没有足够的“点数”将其标记为LiveWare。据我所知,索尼智能手表和LiveView寻呼机都使用LiveWare。我曾设想,如果我能向LiveView设备发送通知,该设备也将适用于索尼智能手表。无论如何,该示例不适用于LiveView设备。