mattak's blog

気の向くままに書く

ゲームブートキャンプ11日目

今日やること

ちょっと遊びすぎた。

01:00-01:30

Setupつづき

proguard-project.txtに追加

-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

まちがってるがな。s/gradle.build/build.gradle/g

Note: When using Android Studio, you must add Proguard to your gradle.build file's build types. For more information, see the Gradle Plugin User Guide.

Google Play services APKを利用できるかチェック

Google Play Servicesにアクセスする

GoogleApiClientを利用する (GoogleDrive)

GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
    .addApi(Drive.API)
    .addScope(Drive.SCOPE_FILE)
    .build();

connect()でつなぐ前にcallbackをimplementする

public class MyActivity extends FragmentActivity
        implements ConnectionCallbacks, OnConnectionFailedListener {
    private GoogleApiClient mGoogleApiClient;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Create a GoogleApiClient instance
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Drive.API)
                .addScope(Drive.SCOPE_FILE)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
        ...
    }
    @Override
    protected void onStart() {
        super.onStart();
        if (!mResolvingError) {  // more about this later
            mGoogleApiClient.connect();
        }
    }
    @Override
    protected void onStop() {
        mGoogleApiClient.disconnect();
        super.onStop();
    }
    @Override
    public void onConnected(Bundle connectionHint) {}
    @Override
    public void onConnectionSuspended(int cause) {}
    @Override
    public void onConnectionFailed(ConnectionResult result) {}
}