Search code examples
androidwear-osintentfilter

Different activities for different device's type


I have an application for smartphones. In my AndroidManifest.xml file placed activity with special intent-filter

    <activity
        android:name=".feature.splashscreen.SplashScreenVm"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Now, I need to launch my application on wearable devices. Obviously, default activity for wearable device should be WearableActivity.class. How to configure my AndroidManifest.xml to launch different activities depending on device's type? Or maybe it should be handled not by manifest?


Solution

  • As far as i know, for wearable devices(e.g watches), you need to have a different apk. It currently is not possible to create a single APK that works on a phone and watch. for more info you can check : https://developer.android.com/training/wearables/apps/packaging.html

    EDIT:

    I also found a tutorial about how to do what you plan; https://medium.com/@manuelvicnt/android-wear-add-a-wear-app-to-your-already-existing-android-app-2a668442dd0a