【问题标题】:Sony SmartWatch Control Extension, displaying a view from my AppSony SmartWatch Control Extension,显示来自我的应用程序的视图
【发布时间】:2014-07-28 02:19:53
【问题描述】:
我想在我的智能手表上显示我现有应用程序 XYZ 的输出(位图)。我知道,控制 API 是要走的路,但索尼 SDK 和开源项目(8Game 和 MusicPlayer)中的现有示例对我来说并不清楚。我的假设是否正确,我需要将以下类集成到我现有的应用程序中?
MyControlWatch.java
MyExtensionReceiver.java
MyExtensionService.java
MyRegistrationInformation.java
我还需要什么?如何让 SmartWatch 显示我的位图?我是否必须发送CONTROL_START_REQUEST_INTENT,如果是,我应该从哪里发送?我必须从给定的 SampleControlExtension 更改什么才能获得结果?
【问题讨论】:
标签:
android
sony
sony-smartwatch
【解决方案1】:
是的,这些是显示控件扩展所需的类。您不一定需要发送 CONTROL_START_REQUEST_INTENT。仅当您想从另一个扩展程序启动您的控制扩展程序时。
查看 SDK 的 /samples 目录中包含的 SampleControlSmartWatch.java 类中的示例代码。查看 Animation() 类构造函数以获取示例。本质上,您需要创建一个布局,然后添加您的位图,然后调用 showBitmap()。
【解决方案2】:
Sony 应该创建可用于此类 u.u 的迷你教程
/**
* 这是一个如何更新整个布局和一些
* 意见。对于每个视图,都使用一个包。此捆绑包必须具有布局
* 参考,即视图 ID 和要使用的内容。这种方法
* 更新一个 ImageView 和一个 TextView。
*
* @see Control.Intents#EXTRA_DATA_XML_LAYOUT
* @see Registration.LayoutSupport
*/
private void updateLayout() {
mCount = 0;
mIconImage = true;
String caption = mContext.getString(R.string.text_tap_to_update);
// Prepare a bundle to update the button text.
Bundle bundle1 = new Bundle();
bundle1.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.btn_update_this);
bundle1.putString(Control.Intents.EXTRA_TEXT, caption);
// Prepare a bundle to update the ImageView image.
Bundle bundle2 = new Bundle();
bundle2.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.image);
bundle2.putString(Control.Intents.EXTRA_DATA_URI,
ExtensionUtils.getUriString(mContext, R.drawable.icon_extension48));
Bundle[] bundleData = new Bundle[2];
bundleData[0] = bundle1;
bundleData[1] = bundle2;
showLayout(R.layout.layout, bundleData);
}