1

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.

Gofurs
  • 53
  • 8

1 Answers1

1

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.

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59
  • thanks you, I already saw the documentation and this is not my case, my problem is not there, my app works fine offline and it stores a local backup and then synchronized with drive, but the problem is when a service got the notification and the app is closed or in background the main functionality works fine, but the only problem with the app can't run the backup module when the app is closed , so what am trying to do is a service who will access to my SQLite & SharedPreference and get Data is it possible or any sample available ! – Gofurs Sep 30 '16 at 15:23