[英]How to start mobile app from wear app?
我有一個Android Wear應用程序,可以從配套的移動應用程序發送消息。 當移動應用程序處於活動狀態時,所有運行正常,如果配套移動應用程序未激活我需要能夠從磨損應用程序啟動它...如何從磨損應用程序啟動移動應用程序?
您可以在移動應用程序中實現WearableListenerService,並從Wear應用程序發送消息。 這里有一點要點來實現它。
//移動應用
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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.