我有一个安卓穿戴应用程序,可以发送信息从和同伴移动应用程序。当移动应用程序是活动的所有运行良好,如果同伴移动应用是不活跃的,我需要能够启动它从磨损应用程序.如何从磨损应用程序启动移动应用程序?
发布于 2014-08-04 06:07:40
您可以在您的移动应用程序中实现一个WearableListenerService,并发送来自磨损应用程序的消息。这是实现这一目标的一点要点。
//移动应用程序
public class ListenerServiceFromWear extends WearableListenerService {
private static final String HELLO_WORLD_WEAR_PATH = "/hello-world-wear";
@Override
public void onMessageReceived(MessageEvent messageEvent) {
/*
* Receive the message from wear
*/
if (messageEvent.getPath().equals(HELLO_WORLD_WEAR_PATH)) {
//For example you can start an Activity
Intent startIntent = new Intent(this, MyActivity.class);
startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startIntent);
}
}
}你必须在你的申报单上申报。
<service android:name=".ListenerServiceFromWear">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>https://stackoverflow.com/questions/25106353
复制相似问题