I'm trying to integrate the Backup Service with my app. It's all working right up to the moment I make the call to:
BackupManager bm = new BackupManager(context);
bm.dataChanged();
I see the following in my Logcat:
W/BackupManagerService﹕ dataChanged but no participant pkg='com.company.app' uid=10102
Here's my implementation of BackupAgentHelper
https://gist.github.com/cloakedninjas/fe135cb04bf324e26b0c if it helps...
public class CordovaBackupAgentHelper extends BackupAgentHelper {
static final String FILE_NAME = "gameData.json";
static final String FILES_BACKUP_KEY = "data_file";
@Override
public void onCreate() {
FileBackupHelper helper = new FileBackupHelper(this, FILE_NAME);
addHelper(FILES_BACKUP_KEY, helper);
}
@Override
public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
ParcelFileDescriptor newState) throws IOException {
Log.d(Backup.LOG_TAG, "Backup requested: " + oldState.toString() + " | " + newState.toString());
synchronized (Backup.sDataLock) {
Log.d(Backup.LOG_TAG, "Backup requested: " + data.toString());
super.onBackup(oldState, data, newState);
}
}
@Override
public void onRestore(BackupDataInput data, int appVersionCode,
ParcelFileDescriptor newState) throws IOException {
synchronized (Backup.sDataLock) {
Log.d(Backup.LOG_TAG, "Restore given: " + data.toString());
super.onRestore(data, appVersionCode, newState);
}
}
}
I never see my log entry Backup requested
. I've checked my Android manifest has the following attribute android:backupAgent="CordovaBackupAgentHelper"
Can anyone shed any light on this?
Update
I've noticed if I change my Manifest to have android:backupAgent="FooBar"
I see no errors about undeclared class FooBar, but still see dataChanged but no participant pkg
when attempting a backup. So my guess is the error is related to not being able to find my backup agent.
So my issue was not putting the attributes onto the correct element :(
I had:
<manifest android:backupAgent="com.cloakedninjas.cordova.plugins.BackupAgentHelper" ...
Instead of:
<application android:backupAgent="com.cloakedninjas.cordova.plugins.BackupAgentHelper"
...