original source : https://developer.android.com/training/wearables/apps/standalone-apps.html

Planning Your Apps

Generally, the minimum and target API level for a standalone app, and for Wear 2.0, is level 25. The minimum SDK level can be 23 only if you are using the same APK for Wear 1.0 and 2.0

1.0의 경우는 wearable apk가 mobile apk에 포함되어있다. 2.0의 경우에는 분리되어야 하며 각각 따로 google play에 올려져야한다.

Identifying an app as standalone

watch app이 완전 또는 semi 완전하게 독립된 app인경우. watch app의 manifest 에 아래사항을 기입한다.

<application>
...
 <meta-data
   android:name="com.google.android.wearable.standalone"
   android:value="true" />
...
</application>

Shared Code and Data Storage

  • Code can be shared between a Wear app and a phone app.
  • You can use standard Android storage APIs to store data locally. For example, you can use the SharedPreferences APIs, SQLite, or internal storage

Detecting Your App on Another Device

Your phone app or watch app can use the CapabilityApi to advertise the app’s presence to a paired device. It can do so statically and dynamically. When an app is on a node in a user’s Wear network (i.e., on a phone, paired watch, or in the cloud)

Specifying capability names for detecting your apps

For the app corresponding to each device type (watch or phone), specify a unique string for the capability name in the res/values/wear.xml file(mobile쪽에서 또 watch 쪽에서도 양쪽다).

App detection and opening a URL from a watch

  1. Use the CapabilityApi to check if your phone app is installed on the paired phone. For more information, see the sample.
  2. If your phone app isn’t installed on the phone, use the PhoneDeviceType.getPhoneDeviceType() method to check the type of the phone.
  3. If PhoneDeviceType.DEVICE_TYPE_ANDROID is returned, the phone is an Android phone. Call RemoteIntent.startRemoteActivity() on the Wear device to open the app store on the phone. Use the market URI for your phone app (which may be different from your phone URI). For example, use a market URI such as: market://details?id=com.example.android.wearable.wear.finddevices
  4. If PhoneDeviceType.DEVICE_TYPE_IOS is returned, it means the phone is an iOS phone (with no Play Store available). Open the App Store on the iPhone by calling RemoteIntent.startRemoteActivity() on the Wear device. You can specify your app’s iTunes URL, e.g., https://itunes.apple.com/us/app/yourappname. On an iPhone, from Android Wear, you cannot programmatically determine if your phone app is installed. As a best practice, provide a mechanism to the user (e.g., a button) to manually trigger the opening of the App Store.

Details for detecting the type of paired phone

int phoneDeviceType =
PhoneDeviceType.getPhoneDeviceType(context);

App detection starting from an Android phone

  1. Using the NodeApi, find all watches connected to the user’s phone. For more information, see the sample.
  2. Using the CapabilityApi, check which of the user’s watches have your app installed.
  3. If your app isn’t installed on all of the user’s watches (compare the results from Step 1 with the results from Step 2), allow the user to open the Play Store on the remaining Wear devices from the phone via the RemoteIntent.startRemoteActivity() method. Specifically, use the market URI for the Wear app (which may be different from your phone app’s URI). For example, use a market URI such as: market://details?id=com.example.android.wearable.wear.finddevices

Comments are closed.

Post Navigation