diff options
author | daneren2005 <daneren2005@gmail.com> | 2013-07-23 14:36:43 -0700 |
---|---|---|
committer | daneren2005 <daneren2005@gmail.com> | 2013-07-23 14:36:43 -0700 |
commit | 488affb4cdbb005448e9ed18a46972b291303312 (patch) | |
tree | de942facaafaba456891a4a763e797cd66b308ed | |
parent | 7a626af446af8a7a2bae7ff1f4fd7b4ca4c657ef (diff) | |
download | dsub-488affb4cdbb005448e9ed18a46972b291303312.tar.gz dsub-488affb4cdbb005448e9ed18a46972b291303312.tar.bz2 dsub-488affb4cdbb005448e9ed18a46972b291303312.zip |
Start a backup sync when settings are changed
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java index f5aea74a..9d0aa1ba 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java @@ -200,6 +200,24 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer DownloadService downloadService = DownloadServiceImpl.getInstance(); downloadService.setSleepTimerDuration(Integer.parseInt(sharedPreferences.getString(key, "60"))); } + + scheduleBackup(); + } + + private void scheduleBackup() { + try { + Class managerClass = Class.forName("android.app.backup.BackupManager"); + Constructor managerConstructor = managerClass.getConstructor(Context.class); + Object manager = managerConstructor.newInstance(this); + Method m = managerClass.getMethod("dataChanged"); + m.invoke(manager); + Log.d(TAG, "Backup requested"); + } catch(ClassNotFoundException e) { + Log.d(TAG, "No backup manager found"); + } catch(Throwable t) { + Log.d(TAG, "Scheduling backup failed " + t); + t.printStackTrace(); + } } private void update() { |