Android 磨损意图过滤器

Android Wear Intent Filter

我正在尝试使用自定义 intent 过滤器来调用 android 磨损 activity。 (不确定这是最好的主意吗?)但是,在 wear 应用程序上注册 intent 过滤器并部署移动应用程序后,我收到错误:

Applications have the same package name com.nybblemouse.datalayerdatamap:
    mobile, wear

有人可以提供一些建议吗?

背景资料:

我正在开发一个 android wear 应用程序,它使用数据层 API 允许 http 连接命中一个简单的 API 并在手表应用程序上显示响应.

我已经使用数据层API让手机APP调用成功,现在想调用手表上的activity显示结果。

Android 佩戴清单:

  <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.DeviceDefault" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="com.nybblemouse.datalayerdatamap.MainActivity" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <service android:name=".ListenerService">
            <intent-filter>
                <action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
            </intent-filter>
        </service>
    </application>

在我单独的监听器服务中class(对于数据层api),http响应成功后:

Intent chilliIntent = new Intent();
chilliIntent.setAction("com.nybblemouse.datalayerdatamap.MainActivity");
chilliIntent.putExtra("CHILLIS", "10");
startActivity(chilliIntent);

经过一些广泛的研究,我创建了一个示例 Android Studio 项目来演示如何实现这一点。简而言之,所有网络流量都需要经过AndroidWearAPI,即MessageAPI或Data LayerAPI。据传,在 2015 年 5 月 27 日即将举行的 Google IO 活动中,这会有所改变,支持 Wear 设备上的本机 wifi。

从移动设备调用 Wea​​r 设备上的 activity 的过程如下(假设您选择了数据层 API):

  1. 创建 Intent 中发送所需数据的数据映射。
  2. 使用适当的回调创建一个新的数据层 API 对象
  3. 使用节点 API,循环遍历节点或使用数据层 API 发送方方法广播到您选择的节点。
  4. 在 Wear 设备上,使用所需的回调实现服务数据层 API class
  5. 使用 OnDataChanged 回调,侦听您发送的数据映射,并根据需要提取数据
  6. 照常使用 Intent 从 OnDataChanged 方法启动 activity。

我已经用 DFD、幻灯片和示例项目对此进行了非常详尽的记录。您可以在我的 Github 项目中查看它们:

https://github.com/kirgy/fandos

该项目于 2015 年 5 月提交给英国布里斯托尔的西南移动用户组: http://www.meetup.com/swmobile/events/220749834/