I am developing an Android application that should allow read and write access to Google Drive. In addition, it must work on public devices (this means that many people can use the same device to access their Google account). In such circumstances, it is unacceptable to add each user account to Android Account Manager. Unfortunately, all official manuals use authentication with the google account registered on the device. A pop-up window will appear to select existing google accounts from the device or add a new one.
protected void onStart() { super.onStart(); if (mGoogleApiClient == null) { mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Drive.API) .addScope(Drive.SCOPE_FILE) // Optionally, add additional APIs and scopes if required. .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); } mGoogleApiClient.connect(); } /** * Called when {@code mGoogleApiClient} is trying to connect but failed. * Handle {@code result.getResolution()} if there is a resolution * available. */ @Override public void onConnectionFailed(ConnectionResult result) { Log.i(TAG, "GoogleApiClient connection failed: " + result.toString()); if (!result.hasResolution()) { // Show a localized error dialog. GooglePlayServicesUtil.getErrorDialog( result.getErrorCode(), this, 0, new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { retryConnecting(); } }).show(); return; } // If there is an existing resolution error being displayed or a resolution // activity has started before, do nothing and wait for resolution // progress to be completed. if (mIsInResolution) { return; } mIsInResolution = true; try { result.startResolutionForResult(this, REQUEST_CODE_RESOLUTION); } catch (SendIntentException e) { Log.e(TAG, "Exception while starting resolution activity", e); retryConnecting(); } }
What is the workaround? I need to login to google account (actually only to disk) without saving the account on the device. I just need to log in and log out when done, without leaving any personal data on the device. How can i do this?
source share