我想做一个易于佩戴的应用程序,并通过数据层进行连接。使用手持模块(使用:S5)时一切正常,但佩戴设备(使用:Moto 360)总是出现错误:
onConnectionFailed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null}
手持设备上的play服务已经更新到最新版本。
我已经添加了
compile 'com.google.android.gms:play-services:7.3.0'
需要同时给手持设备和可穿戴设备构建build.gradle文件。
可穿戴设备Activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
@Override
public void onLayoutInflated(WatchViewStub stub) {
mTextView = (TextView) stub.findViewById(R.id.text);
}
});
int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
Log.i(TAG,"Services available: "+ result);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(Bundle connectionHint) {
Log.d(TAG, "onConnected: " + connectionHint);
// Now you can use the Data Layer API
}
@Override
public void onConnectionSuspended(int cause) {
Log.d(TAG, "onConnectionSuspended: " + cause);
}
})
.addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult result) {
Log.d(TAG, "onConnectionFailed: " + result);
}
})
// Request access only to the Wearable API
.addApi(Wearable.API)
.build();
}
@Override
protected void onStart() {
super.onStart();
Log.i(TAG, "==OnStart===");
mGoogleApiClient.connect();
}
我已经做过研究,但是没有找到任何可行的解决方案。