不同设备类型的不同活动

Different activities for different device's type

我有一个智能手机应用程序。在我的 AndroidManifest.xml 文件中放置 activity 特殊 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>

现在,我需要在可穿戴设备上启动我的应用程序。显然,可穿戴设备的默认 activity 应该是 WearableActivity.class。如何配置我的 AndroidManifest.xml 以根据设备类型启动不同的活动?或者也许它不应该由清单处理?

据我所知,对于可穿戴设备(例如手表),您需要有不同的 apk。 目前无法创建适用于 phone 和手表的单个 APK。 有关更多信息,您可以查看: https://developer.android.com/training/wearables/apps/packaging.html

编辑:

我还找到了有关如何按照您的计划进行操作的教程; https://medium.com/@manuelvicnt/android-wear-add-a-wear-app-to-your-already-existing-android-app-2a668442dd0a

apk 确实不同。我建议您是否为功能有限的可穿戴设备构建第二个应用程序,或者只构建智能手机应用程序中的重要功能。请注意,可穿戴设备的屏幕空间有限,因此您可能只想将其用于通知等用途。