私は自分のアプリに MapFragment を追加しており、マップのチュートリアルから改作された次のコードがあります。
private boolean servicesConnected() {
// Check that Google Play services is available
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
// If Google Play services is available
if (ConnectionResult.SUCCESS == resultCode) {
// In debug mode, log the status
Log.d("Location Updates", "Google Play services is available.");
// Continue
return true;
// Google Play services was not available for some reason
} else {
GooglePlayServicesUtil.getErrorDialog(resultCode, this, 7).show();
return false;
}
}
古いGoogle Playサービスを使用して、工場出荷時の状態にリセットされたGalaxy tab 10.1でテストしています。そのため、MapFragment を開こうとservicesConnected()
すると、確認のために呼び出すと、予想どおり、Google Play Services が必要であることを示すダイアログが表示されます。ダイアログの下部に [Google Play サービスを取得] ボタンがありますが、クリックしても何も起こりません。私の LogCat は次の出力を生成します。
07-23 15:30:43.580: W/GooglePlayServicesUtil(2515): Google Play services is missing.
07-23 15:30:48.510: E/SettingsRedirect(2515): Can't redirect to app settings for Google Play services
私は次のonConnectionFailed
方法を持っています (基本的には Android 開発者サイトからコピーして貼り付けます):
public void onConnectionFailed(ConnectionResult connectionResult) {
/*
* Google Play services can resolve some errors it detects.
* If the error has a resolution, try sending an Intent to
* start a Google Play services activity that can resolve
* error.
*/
if (connectionResult.hasResolution()) {
try {
// Start an Activity that tries to resolve the error
connectionResult.startResolutionForResult(
this,
CONNECTION_FAILURE_RESOLUTION_REQUEST);
/*
* Thrown if Google Play services canceled the original
* PendingIntent
*/
} catch (IntentSender.SendIntentException e) {
// Log the error
e.printStackTrace();
}
} else {
/*
* If no resolution is available, display a dialog to the
* user with the error.
*/
GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 7).show();
}
}
なぜこれが機能しないのですか?どんな助けでも素晴らしいでしょう。
ここに私が取り組んでいる Android dev ページがあります。また、それに関連する SO の投稿もここにあります。
編集
デバイスに Google アカウントが設定されていないことに気付いたので、設定しましたが、違いはありませんでした。