应用程序未显示在 Huawei Watch 2 的应用程序菜单中

App doesn't show up in the apps menu on Huawei Watch 2

我正在 Android Studio 中实现一个应用程序。我 运行 在使用我的 Huawei Watch 2 时遇到问题。该应用程序运行良好,但我不明白为什么它没有显示在手表的应用程序菜单中。

转到设置 -> 应用和通知 -> 信息应用,我看到了我的应用。

这是怎么回事,我该如何解决?

这是我的 Manifest.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.prova._poc">

    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <uses-feature android:name="android.hardware.type.watch" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@android:style/Theme.DeviceDefault"
        tools:ignore="GoogleAppIndexingWarning"
        tools:targetApi="ice_cream_sandwich">

        <service
            android:name=".MyfirebaseMessagingService" android:exported="false" >
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>

        <service
            android:name=".MyFirebaseInstanceIDService" android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>

        <uses-library
            android:name="com.google.android.wearable"
            android:required="true" />
        <!--
               Set to true if your app is Standalone, that is, it does not require the handheld
               app to run.
        -->
        <meta-data
            android:name="com.google.android.wearable.standalone"
            android:value="true" />

        <!-- [START fcm_default_channel] -->
        <!-- [START fcm_default_channel] -->
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="@string/default_notification_channel_id" />

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="gizmos"
                    android:scheme="example" />
            </intent-filter>
        </activity>
        <activity android:name=".Splash">

            <intent-filter>
                <action android:name="Splash" />
                    <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>

</manifest>

在您的 phone 上安装应用程序不会自动将它们安装在您的手表上。如果您转到 Play 商店应用,然后从正面屏幕向下滚动,您会在 phone 上看到一个标有 Apps 的标题:这些是 phone 上所有具有 Wear OS 配套应用,您可以通过点击右侧的任意按钮来安装。

您的主要 Activity 的清单条目是错误的。具体来说,要使其出现在任何 Android 设备上的应用程序启动器中,它需要一个如下所示的 <intent-filter> 元素:

<intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

我不确定为什么要在其中添加所有其他内容,但如果需要,请为其创建第二个 <intent-filter> 元素。对于给定的 <activity>,您可以有多个 intent-filters,匹配不同的意图 - 但是启动器的应该 包含 actioncategory 显示在这里。

更多信息在这里:https://developer.android.com/guide/components/intents-filters.html