9

このメソッドは 0 を返し続けます。開発者ドキュメントによると、デバイスが Google Play の最新バージョンを取得した場合、このメソッドは SUCCES のようなものを返す必要があります。誰もこれを使用する方法を知っていますか?

@Override
    public void onResume() {
        super.onResume();

        GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
        System.out.println("henkie: " + GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()));
    }
4

4 に答える 4

40

戻ってきSUCCESSました。ドキュメントには、メソッドの戻り値の型が int であることが明確に記載されており、

エラーが発生したかどうかを示すステータス コード。ConnectionResult の次のいずれかになります: SUCCESS、SERVICE_MISSING、SERVICE_VERSION_UPDATE_REQUIRED、SERVICE_DISABLED、SERVICE_INVALID。

返されたものを確認するには、次のようなものを使用します。

int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if(status == ConnectionResult.SUCCESS) {
    //Success! Do what you want
}
于 2012-12-07T16:03:56.463 に答える
7

ドキュメントをお読みください:0SUCCESS

public static final int SUCCESS
The connection was successful.
Constant Value: 0 (0x00000000)

ドキュメンテーション

于 2012-12-07T16:02:36.490 に答える
4

単に

int statusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if (statusCode == ConnectionResult.SUCCESS) {
    //OK
}
于 2012-12-07T16:05:58.407 に答える