Android Wear - 在手机上打开 [英] Android Wear - Open on phone
问题描述
我在想,可能有人帮助我。
我有两个应用程序,父移动应用和Android应用程序的磨损
我想添加一个按钮,让Android Wear许多应用程序中打开从腕表父应用程序一样,但我不能似乎发现了什么来帮助我。
到目前为止,我正在这样的事情刚刚播放在手机上打开动画的手表,然后我不知道在哪里可以从那里到实际打开父应用程序。
@覆盖
公共无效的onClick(WearableListView.ViewHolder viewHolder){
开关(viewHolder.getPosition()){
情况下0:
//做一点事
意向意图=新意图(这一点,SelectActivity.class);
startActivity(意向);
打破;
情况1:
//做别的事情
打破;
案例2:
意图intentOpen =新意图(背景下,ConfirmationActivity.class);
intentOpen.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE,ConfirmationActivity.OPEN_ON_PHONE_ANIMATION);
startActivity(intentOpen);
打破;
}
}
您需要创建一个WearableListenerService。如何做一个很好的例子是在这里:
https://gist.github.com/gabrielemariotti/117b05aad4db251f7534
一旦你收到消息,你可以打开使用具有以下意图父应用程序:
getApplicationContext()startActivity(意向);
I was wondering could anybody help me. I have two applications, the parent mobile application and the android wear application.
I want to add a button to open the parent application from the watch like in many applications for android wear but I cant seem to find anything to help me.
So far I'm running something like this which just plays the open on phone animation on the watch and then I'm not sure where to go from there to actually open the parent application.
@Override
public void onClick(WearableListView.ViewHolder viewHolder) {
switch (viewHolder.getPosition()) {
case 0:
//Do something
Intent intent = new Intent(this, SelectActivity.class);
startActivity(intent);
break;
case 1:
//Do something else
break;
case 2:
Intent intentOpen = new Intent(context, ConfirmationActivity.class);
intentOpen.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, ConfirmationActivity.OPEN_ON_PHONE_ANIMATION);
startActivity(intentOpen);
break;
}
}
You need to create a WearableListenerService. A good example of how to do that is here:
https://gist.github.com/gabrielemariotti/117b05aad4db251f7534
Once you receive the message you can open the parent application using an intent with the following:
getApplicationContext().startActivity(intent);
这篇关于Android Wear - 在手机上打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!