Java 类android.app.backup.RestoreObserver 实例源码
项目:Key-Value-Backup-API-Sample
文件:MainActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.create:
createTestFiles();
break;
case R.id.restore:
new BackupManager(this).requestRestore(new RestoreObserver() {
@Override
public void restoreFinished(int error) {
if (error == 0) {
Toast.makeText(MainActivity.this, R.string.files_restored, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, getString(R.string.restore_failed, error), Toast.LENGTH_SHORT).show();
}
}
});
break;
}
return super.onOptionsItemSelected(item);
}
项目:geoPingProject
文件:GeoPingPrefActivity.java
/**
* Click handler, designated in the layout, that runs a restore of the app's
* most recent data when the button is pressed.
*/
public void onRestoreButtonClick(View v) {
Log.v(TAG, "Requesting restore of our most recent data");
BackupManager mBackupManager = new BackupManager(this);
mBackupManager.requestRestore(new RestoreObserver() {
public void restoreFinished(int error) {
/** Done with the restore! Now draw the new state of our data */
if (error == 0) {
Log.v(TAG, "Restore finished, error = " + error);
NotifToasts.showBackupRestored(GeoPingPrefActivity.this);
} else {
Log.e(TAG, "Restore finished with error = " + error);
}
}
});
}
项目:buildAPKsSamples
文件:BackupRestoreActivity.java
/**
* Click handler, designated in the layout, that runs a restore of the app's
* most recent data when the button is pressed.
*/
public void onRestoreButtonClick(View v) {
Log.v(TAG, "Requesting restore of our most recent data");
mBackupManager.requestRestore(
new RestoreObserver() {
public void restoreFinished(int error) {
/** Done with the restore! Now draw the new state of our data */
Log.v(TAG, "Restore finished, error = " + error);
populateUI();
}
}
);
}
项目:Shortcuts
文件:BackupHandler.java
public void requestRestore() {
RestoreObserver restoreObserver = new RestoreObserver() {
@Override
public void onUpdate(int nowBeingRestored, String currentPackage) {
super.onUpdate(nowBeingRestored, currentPackage);
}
};
BackupManager bm = new BackupManager(this);
bm.requestRestore(restoreObserver);
}
项目:GoogleCloudApp_Tutorial
文件:BackupAPI.java
public void requestRestore() {
RestoreObserver restoreObserver = new RestoreObserver() {
@Override
public void onUpdate(int nowBeingRestored, String currentPackage) {
super.onUpdate(nowBeingRestored, currentPackage);
}
};
BackupManager bm = new BackupManager(this);
bm.requestRestore(restoreObserver);
}
项目:cowbird
文件:AnotaProtocolo.java
@Override
public void onCreate() {
super.onCreate();
Long lastCheck = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getLong("lastCheck", -1);
if(lastCheck==-1){
new BackupManager(getApplicationContext()).requestRestore(new RestoreObserver() {
@Override
public void restoreStarting(int numPackages) {
super.restoreStarting(numPackages);
}
@Override
public void onUpdate(int nowBeingRestored, String currentPackage) {
super.onUpdate(nowBeingRestored, currentPackage);
}
@Override
public void restoreFinished(int error) {
super.restoreFinished(error);
Log.i(Constants.LOG_TAG, "REstore finalizou " + error);
Toast.makeText(getApplicationContext(), "Restoure completou " + error, Toast.LENGTH_SHORT).show();
CrawlSMSInbox.startCrawlingSMSInbox(getApplicationContext());
}
});
}else {
CrawlSMSInbox.startCrawlingSMSInbox(getApplicationContext());
}
}
项目:SafeSlinger-Android
文件:SafeSlinger.java
private boolean requestRestore(Context ctx) {
BackupManager bm = new BackupManager(ctx);
RestoreObserver restoreObserver = new RestoreObserver() {
@Override
public void restoreStarting(int numPackages) {
sRestoring = true;
showNote(R.string.prog_SearchingForBackup);
}
@Override
public void restoreFinished(int error) {
sBackupExists = (error == 0);
sRestoring = false;
// we passed backup restore, now we can load databases...
doUpgradeDatabaseInPlace();
}
};
try {
int res = bm.requestRestore(restoreObserver);
return res == 0 ? true : false;
} catch (NullPointerException e) {
// catch failure of RestoreSession object to manage itself in the
// following:
// android.app.backup.RestoreSession.endRestoreSession(RestoreSession.java:162)
// android.app.backup.BackupManager.requestRestore(BackupManager.java:154)
return false;
}
}
项目:2048-Battles
文件:GameFragment.java
public void requestRestore() {
Log.d(LOG_TAG, "request restore");
BackupManager bm = new BackupManager(getActivity());
bm.requestRestore(
new RestoreObserver() {
@Override
public void restoreStarting(int numPackages) {
Log.d(LOG_TAG, "Restore from cloud starting.");
Log.d(LOG_TAG, "" + gameData.getTotalMoves());
super.restoreStarting(numPackages);
}
@Override
public void onUpdate(int nowBeingRestored, String currentPackage) {
Log.d(LOG_TAG, "Restoring " + currentPackage);
super.onUpdate(nowBeingRestored, currentPackage);
}
@Override
public void restoreFinished(int error) {
Log.d(LOG_TAG, "Restore from cloud finished.");
super.restoreFinished(error);
Log.d(LOG_TAG, "" + gameData.getTotalMoves());
Log.d(LOG_TAG, "calling load");
load();
}
});
}