0
因此,我通過Sony Smartwatch 3運行代碼,並且我在使用GoogleApiClient的isConnected()函數時遇到了一些問題。我正在運行的代碼如下。Sony Smartwatch 3 Google Play Services需要更新
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setAmbientEnabled();
mContainerView = (BoxInsetLayout) findViewById(R.id.container);
mTextView = (TextView) findViewById(R.id.text);
mClockView = (TextView) findViewById(R.id.clock);
initGoogleApiClient();
if (googleApiClient.isConnected() == true) {
setContentView(R.layout.connected);
} else {
setContentView(R.layout.notconnected);
}
}
private void initGoogleApiClient() {
if (googleApiClient != null && googleApiClient.isConnected())
Log.d(TAG, "Connected");
else {
googleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(@Nullable Bundle bundle) {
Log.d(TAG, "onConnected: " + bundle);
}
@Override
public void onConnectionSuspended(int i) {
Log.d(TAG, "onConnectionSuspended: " + i);
}
})
.addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Log.d(TAG, "onConnectionFailed: " + connectionResult);
}
})
.addApi(Wearable.API)
.build();
googleApiClient.connect();
}
}
此代碼位於我的活動類中。正如你所看到的,它所做的只是初始化GoogleApiClient並檢查它是否已連接。我繼續在我的logcat中發出以下警告。
d/CheckConnection:onConnectionFailed:ConnectionResult {的StatusCode = SERVICE_VERSION_UPDATE_REQUIRED,分辨率= NULL,消息= NULL}
然而,我的索尼Smartwatch 3表將不會更新其谷歌播放服務,而當我稱他們的負荷消費服務,我不斷被告知我的手錶不支持最新版本的Google Play服務。有沒有人已經找到解決這個問題的方法?如果是這樣,請你幫我一下嗎?謝謝
我已經嘗試從gradle構建版本更改谷歌播放服務的版本,但是這並不適用於我。你有什麼其他的建議? – Bobulubadu
不是。如果您的手錶顯示類似「8.7.x」的內容,則在應用程序和可穿戴build.gradle中使用「8.4.0」應該有所幫助。看看鏈接的帖子,特別是在Wayne Piekarski的解釋中。 –