Android 如何从程序代码启动SmartWatch扩展?
我想知道从程序代码启动SmartWatch扩展的方法。例如,意图等。 前几天我在Google Play上注册了SmartWatch的脚本语言。 它分为两个程序,一个注册为SmartWatch Extension(BitmapCatcher),另一个注册为智能手机应用程序(Luarida)。 脚本从智能手机开始。在这里,我想在启动脚本的同时启动BitmapCatcher。 虽然人们认为,如果INTENT被发送到LiveWare,BitmapCatcher可以在无需触摸屏幕的情况下启动,但这种方式并不为人所知 请设定在不触摸屏幕的情况下启动SmartWatch Extension的程序代码 (当我在一个索尼移动网站的Smart Extras讨论中写下这个问题时,建议在这个网站上问杰克先生。)Android 如何从程序代码启动SmartWatch扩展?,android,sony,sony-smartwatch,Android,Sony,Sony Smartwatch,我想知道从程序代码启动SmartWatch扩展的方法。例如,意图等。 前几天我在Google Play上注册了SmartWatch的脚本语言。 它分为两个程序,一个注册为SmartWatch Extension(BitmapCatcher),另一个注册为智能手机应用程序(Luarida)。 脚本从智能手机开始。在这里,我想在启动脚本的同时启动BitmapCatcher。 虽然人们认为,如果INTENT被发送到LiveWare,BitmapCatcher可以在无需触摸屏幕的情况下启动,但这种方式并
SmartWatch扩展无法从其他Android应用程序启动,尽管根据您的解释进行了测试。请再教一遍。
我应该在“Your.package.name”中写什么?
此外,我应该在“HostAppPackageName”中写些什么
以sendBroadcast开头的是BitmapCatcher。此包名为“com.luaridaworks.smartwatch.bitmapcatcher”。
在测试程序中,它编写如下。它继续发表以下评论
package com.luaridaworks.test02;
import com.sonyericsson.extras.liveware.aef.control.Control;
import com.sonyericsson.extras.liveware.aef.registration.Registration;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Test02Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "com.luaridaworks.smartwatch.bitmapcatcher");
intent.setPackage("com.luaridaworks.smartwatch.bitmapcatcher");
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
}
}
因为BitmapCatcher没有启动,所以Intent被重写如下,并进行了测试
intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "com.luaridaworks.smartwatch.bitmapcatcher");
intent.setPackage("com.sonyericsson.extras.liveware");
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
它的开始并非如此。意图被改写如下并测试
intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "com.luaridaworks.smartwatch.bitmapcatcher");
intent.setPackage("com.luaridaworks.test02");
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "com.luaridaworks.test02");
intent.setPackage("com.luaridaworks.smartwatch.bitmapcatcher");
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "com.sonyericsson.extras.liveware");
intent.setPackage("com.luaridaworks.smartwatch.bitmapcatcher");
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
它的开始并非如此。意图被改写如下并测试
intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "com.luaridaworks.smartwatch.bitmapcatcher");
intent.setPackage("com.luaridaworks.test02");
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "com.luaridaworks.test02");
intent.setPackage("com.luaridaworks.smartwatch.bitmapcatcher");
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "com.sonyericsson.extras.liveware");
intent.setPackage("com.luaridaworks.smartwatch.bitmapcatcher");
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
它的开始并非如此。意图被改写如下并测试
intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "com.luaridaworks.smartwatch.bitmapcatcher");
intent.setPackage("com.luaridaworks.test02");
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "com.luaridaworks.test02");
intent.setPackage("com.luaridaworks.smartwatch.bitmapcatcher");
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "com.sonyericsson.extras.liveware");
intent.setPackage("com.luaridaworks.smartwatch.bitmapcatcher");
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
它的开始并非如此。它还没有成功。请给出代码为com.luaridaworks.test02的程序示例,其中“com.luaridaworks.smartwatch.bitmapcatcher”通常从应用程序启动。
您通过发送SDK实用程序类中定义的启动请求意图来请求启动扩展。在API规范的第6.1章中也有相关参考 引用“your.package.name”是注册扩展时存储到扩展数据库的包名。如果查看SDK中的示例,每个扩展示例都有一个SampleRegistrationInformation,其中包含一个getExtensionRegistrationConfiguration方法。这是注册通过ContentProvider存储到数据库的地方。下一行存储您的包名
values.put(Registration.ExtensionColumns.PACKAGE_NAME, mContext.getPackageName());
从您的示例来看,我认为您的包名是“com.luaridaworks.smartwatch.bitmapcatcher”
hostAppPackageName是SmartWatch主机应用程序的程序包名称。有关此程序包名称的信息会随主机应用程序发送。在SDK示例中,我们将主机应用程序包名称存储在一个全局变量中,以供以后使用,因此代码中引用了hostAppPackageName。关于这一点,我在第二节中讲得更多一些。如果要硬编码主机应用程序包名称,请选择:com.sonyericsson.extras.smartwatch但我建议您不要,因为它可能在未来发生变化
因此,以下(硬编码)应该适合您:
Intent intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "com.luaridaworks.smartwatch.bitmapcatcher");
intent.setPackage("com.sonyericsson.extras.smartwatch");
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
很抱歉。
由于评论中没有正确显示程序代码,因此评论内容如下所示。非常感谢。根据您的解释编写代码时,启动成功。我知道这是“com.sonyericsson.extras.smartwatch”,将来可能会改变。但是,由于只生成一个奇怪的操作,所以它会写入。它是在使用SmartWatch充电时生成的。(下一步,它继续)控制启动请求意图在充电状态下传输到SmartWatch。然后,目标SmartWatch扩展启动。接下来,传输控制\停止\请求\意图。然后,SmartWatch扩展结束,并返回充电模式。即使传输了控制\启动\请求\意图,它也不会在此之后启动。有必要让他们醒来,按下一个硬按钮重新开始。这个规格对我来说不是问题。