Reputation: 53
I'm trying to access to Google Drive Android API when my App runs in the background the client is automatically disconnected, is there any method to keep the client connected while in the background or to connect the client.
public void scheduleBackgroundBackup(){
getP().edit().putBoolean(UPDATE_BACKUP, true).apply();
Log.d("--->BACKGROUND ","scheduling BACKUP");
try{
DriveCore m =CoreApp.getDriveManager();
Log.d("--->BG Client","is Connected :"+m.isConnected()+"");
AppState cs = new AppState (this,
m,
CoreApp.getUserID(),
false);
m.connect();
Log.d("--->BG Client2","is Connected :"+m.isConnected()+"");
m.fetchDriveFiles(DriveMode.BACKGROUND_SAVE,this,cs);
}catch (Exception e){
e.printStackTrace();
Log.d("--->BG BACKUP","Cannot Load Drive Core");
}
updateBackupBackground();
}
so after this code I knew that the user is automatically disconnected in the background.
Upvotes: 1
Views: 619
Reputation: 13469
Yes, Google API support running apps in background. But for Google Drive, I can't see any documentation regarding the connection when in background. However, I have found a documentation which might help.
According to this documentation, the Drive Android API lets your app access files even if the device is offline. To support offline cases, the API implements a sync engine, which runs in the background to upstream and downstream changes as network access is available and to resolve conflicts.
You can check on this related SO question.
Upvotes: 1