Reputation: 71
I have an android wear app, in which I want to have a continue on device button which launches the companion app on the mobile device.
When the App is already launched I can "restart" it using this Remote Intent. How can I start the companion app from a standstill?
Intent intentAndroid = new Intent(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
.setData(Uri.parse("myApplication"));
RemoteIntent.startRemoteActivity(context, intentAndroid, null);
Thanks in advance.
Upvotes: 1
Views: 1015
Reputation: 71
I finally figured it out. I missed adding an intent filter in the android manifest for the activity I wanted to start. For example:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myAppName" android:host="MainActivity" />
</intent-filter>
Then you can start it from the watch using:
Intent intentAndroid = new Intent(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
.setData(Uri.parse("myAppName://MainActivity"));
RemoteIntent.startRemoteActivity(context, intentAndroid, null);
Upvotes: 3