【发布时间】:2016-01-21 01:03:58
【问题描述】:
我正在 Android Wear 上使用 Data Layer,它试图将 DataItem(使用 Data API)从 Wearable (Moto 360 Gen1) 发送到我的移动设备。
但是,没有出现错误或连接失败的迹象,并且没有发送数据。我收到的唯一消息错误是
E/Gms 客户端:无法连接到服务:com.google.android.gms.icing.LIGHTWEIGHT INDEX SERVICE'
在移动设备中:
我创建了一个 Wearable Listener Service 来接收onDataChanged(DataEventBuffer dataEvents)中的数据
Android 清单
<service
android:name=".ListenerService">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
穿着活动:
Activity 的头部看起来像
public class MainActivity extends WearableActivity implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener{
我的 onCreate(..) 函数中有一个 GoogleApiClient:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(AppIndex.API).build();
mGoogleApiClient.connect();
@Override
public void onConnected(Bundle bundle) {
Log.d("Android Wear Connection", "" + mGoogleApiClient.isConnected());
//Data Layer Function uses Data Map
sendAmplitudeDb(10, 2300);
}
我真的卡住了,不知道为什么移动设备没有收到任何数据项,或者为什么可穿戴设备无法连接到 Google Api 客户端...请帮助!
另外,我已经实现了与以下 git repo 几乎相同的代码: https://github.com/LarkspurCA/WearableDataMap
【问题讨论】:
标签: wear-os google-api-client android-wear-data-api dataitem