I am developing an android app that generates files and I need to upload these files to google drive but using only an specific account. Is there a way to do this?
For now I have this code that allows me to choose the account :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
if (connectionResult.hasResolution()) {
try {
connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
} catch (IntentSender.SendIntentException e) {
// Unable to resolve, message user appropriately
}
} else {
GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 0).show();
}
}
Thanks in advance
No. The GoogleApiClient uses the google accounts present on the device to connect and thus the Drive Android API will only be able to fetch/create files on those account. By definition if you want all the clients to backup to a single Drive account, all those client should have the credentials for that account which is not safe.
It sounds like you need a single server endpoint where your clients can connect to and post any data. Look into storage APIs provided by firebase ( https://firebase.google.com/docs/storage/ ) if you want a pre-cooked solution.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.