Sony:SampleNotificationExtension:示例应用程序抛出异常

时间:2013-10-04 23:15:00

标签: android sony sony-smartwatch

我正在尝试向Sony LiveWare设备发送通知

我已安装:com.sonyericsson.extras.liveware.extension.notificationsample,但在尝试运行时遇到错误和异常:

  1. 将偏好设施加载到设备上
  2. 在首选项屏幕上选中“有效”
  3. 在SampleExtensionService中调用以下方法:

    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(this,EXTENSION_SPECIFIC_ID)”返回-1

    我不确定如何更改,但文档说这是一个可选字段。所以我删除了它,看看能不能再进一步了:

    删除sourceId代码时,插入调用会出现异常: “java.lang.SecurityException:您没有足够的权限来执行插入”

    我的环境: HTC One V搭配LiveView手腕寻呼机 http://www.amazon.co.uk/Sony-Ericsson-0001516170-LIVE-VIEW/dp/B00477X6DA 我已经安装了以下应用程序   实时查看   SmartConnect(LiveWare Manager)

    我很感激任何帮助让这个示例工作,或者如果有人知道更简单的方法来为LiveWare做简单的文本通知。

    编辑: 取得了一些进展。在这里找到了一个模拟器: Android的SDK \插件\插件-sony_add-on_sdk_1_0索尼-16 \ apk_files

    我在手机上安装了它。 “SampleExtensionService”在模拟器中工作正常。

    我现在的假设是附加示例与LiveView设备不兼容。

1 个答案:

答案 0 :(得分:3)

不幸的是,SmartExtension API不支持LiveView。相反,LiveView here有一个特定的开发人员工具包。

如果您将来从索尼移动购买更新的可穿戴设备,基于Smart Extension API的通知扩展将可用于多种设备,包括SmartWatch,SmartWatch 2,SBH50,SBH52等。

相关问题