Whenever a user installs my app for the first time an instalationID is generated randomly (say Instalationid =123). I am trying to back up this instalationID, so that when the user uninstalls and then installs my app the old instalationID (123) will be assigned to him again, rather than a new one. After all, he is the same user.
I have a shared preferences file, called SESSION_INFO_PREFERENCE_KEY
, that holds the instalationID and I try to back up the shared preferences file. The back up manager is:
public class ADCBackupAgent extends BackupAgentHelper {
// The name of the SharedPreferences file instalation ID
static final String INSTID = "SESSION_INFO_PREFERENCE_KEY"; //SESSION_INFO_INSTALLATION_UID
// A key to uniquely identify the set of backup data
static final String INSTID_BACKUP_KEY = "inst_id";
// Allocate a helper and add it to the backup agent
@Override
public void onCreate() {
Log.i("OnCreate Method","!!!!!!ON create called!!!!!!!!!!");
SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, INSTID);
addHelper(INSTID_BACKUP_KEY, helper);
}
}
Also, whenever the instalationID is generated for the first time I perform a call to the Back up manager such as:
//this pointing to the current Activity
BackupManager backUpManager = new BackupManager(this);
backUpManager.dataChanged();
For the sake of completenes:
<application
android:icon="@drawable/application_icon"
android:label="@string/app_name"
android:name="MyAppName"
android:theme="@style/FragmentTheme"
android:allowBackup="true"
android:backupAgent=".ADCBackupAgent">
...
<meta-data android:name="com.google.android.backup.api_key" android:value="AEdPqr..." />
</application>
My code works perfectly fine when I do the back up on the local transport (using the bmgr
tool), however, when I try to back up the data on Google's cloud strage I get:
04-28 15:12:24.305: W/BackupTransportService(390): Not ready for backup request right now: [OperationScheduler: enabledState=true lastSuccess=2014-04-03/15:10:49 moratoriumSet=2014-04-28/14:43:18 moratorium=2014-04-29/14:43:18 trigger=1969-12-31/19:00:00]
Furthermore, the onCreate()
Method is never called.
This does not happen when I back up the data on the local transport, i.e., onCreate()
is called and "Not ready for backup request right now" does not appear.