我正在 Android Wear 上工作数据层,它试图将 DataItem(使用 Data API)从可穿戴设备(Moto 360 Gen1)发送到我的移动设备。
但是,没有错误或连接失败的迹象,并且没有发送数据。我收到的唯一消息错误是
E/Gms 客户端:无法连接到服务:com.google.android.gms.icing.LIGHTWEIGHT INDEX SERVICE'
在移动端:
我创建了一个可穿戴侦听器服务来接收数据onDataChanged(DataEventBuffer dataEvents)
安卓清单
<service
android:name=".ListenerService">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
穿着活动:
活动的标题看起来像
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