This sample demonstrates how to connect to an individual’s Google Drive* online storage service from an Android application. I’ll be describing the sections of code that are executed based on the usage flow of the app. This application is based on the Google Drive sample located here. Before you start building this sample, please follow the instructions in the previous link for registering your application with Google Cloud Console.
Like most Android applications, this one begins in the
onCreate function of MainActivity. In this function, you can see the credentials for connecting to the Google Drive account are set up and an activity is started to prompt the user to select their Google account from the registered accounts on the device, or to enter a new one.mCredential = GoogleAccountCredential.usingOAuth2(this, Arrays.asList(DriveScopes.DRIVE));
startActivityForResult(mCredential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);