Example usage for android.app.backup BackupManager dataChanged

List of usage examples for android.app.backup BackupManager dataChanged

Introduction

In this page you can find the example usage for android.app.backup BackupManager dataChanged.

Prototype

public void dataChanged() 

Source Link

Document

Notifies the Android backup system that your application wishes to back up new changes to its data.

Usage

From source file:Main.java

public static void requestBackup(Context context) {
    if (NEED_BACKUP) {
        BackupManager backupManager = new BackupManager(context);
        backupManager.dataChanged();
    }//from  w w  w. j a v a2s  . co m
}

From source file:net.exclaimindustries.geohashdroid.util.KnownLocation.java

/**
 * Stores a bunch of KnownLocations to preferences.  Note that this <b>replaces</b>
 * all currently-stored KnownLocations.//from   w  ww  .java  2 s.co  m
 *
 * @param c a Context
 * @param locations a List of KnownLocations
 */
public static void storeKnownLocations(@NonNull Context c, @NonNull List<KnownLocation> locations) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
    SharedPreferences.Editor edit = prefs.edit();

    JSONArray arr = new JSONArray();

    for (KnownLocation kl : locations) {
        arr.put(kl.serialize());
    }

    // Man, that's easy.
    edit.putString(GHDConstants.PREF_KNOWN_LOCATIONS, arr.toString());
    edit.apply();

    BackupManager bm = new BackupManager(c);
    bm.dataChanged();
}

From source file:com.shalzz.attendance.fragment.SettingsFragment.java

public void requestBackup() {
    BackupManager bm = new BackupManager(mContext);
    bm.dataChanged();
}

From source file:org.gdg.frisbee.android.onboarding.FirstStartActivity.java

private void requestBackup() {
    BackupManager bm = new BackupManager(this);
    bm.dataChanged();
}

From source file:com.zns.comicdroid.activity.Add.java

@Override
public void onStop() {
    if (!mIsScanning) {
        if (mAdapter != null && mAdapter.getCount() > 0) {
            //Backup
            BackupManager m = new BackupManager(this);
            m.dataChanged();
        }//  ww  w  . j a v a2  s  .  c  o  m
    }
    super.onStop();
}

From source file:com.repay.android.adddebt.AddDebtActivity.java

public void requestBackup() {
    BackupManager bm = new BackupManager(this);
    bm.dataChanged();
}

From source file:com.rickendirk.rsgwijzigingen.MainFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1874) {
        //Nieuwe backup van instellingen doen
        BackupManager bm = new BackupManager(getActivity());
        bm.dataChanged();
    }//from www  .j a v  a  2  s  . c o  m
}

From source file:com.andrada.sitracker.tasks.ImportAuthorsTask.java

@Override
protected void onHandleIntent(@Nullable Intent intent) {
    if (intent == null) {
        return;// w  w w.  j  a  v  a2  s  . co  m
    }
    setupExtras(intent);

    this.importProgress = new ImportProgress(authorsList.size());

    //Filter out duplicates right away
    try {
        List<String> urlIds = helper.getAuthorDao().getAuthorsUrlIds();
        Map<String, String> prospectAuthorIds = new HashMap<String, String>();
        for (String auth : authorsList) {
            prospectAuthorIds.put(SamlibPageHelper.getUrlIdFromCompleteUrl(auth), auth);
        }
        for (String urlId : urlIds) {
            if (prospectAuthorIds.containsKey(urlId)) {
                authorsList.remove(prospectAuthorIds.get(urlId));
                this.importProgress.importFail(urlId);
            }
        }
        if (authorsList.size() == 0) {
            EventBus.getDefault().post(new ImportUpdates(this.importProgress));
        }
    } catch (SQLException e) {
        LOGW(TAG, "Failed to filter out duplicate authors", e);
    }

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(android.R.drawable.stat_notify_sync).setOngoing(true).setAutoCancel(false)
            .setContentTitle(getResources().getString(R.string.notification_import_title)).setAutoCancel(true);

    // Creates an explicit intent for an Activity in your app
    Intent resultIntent = new Intent(this, ImportAuthorsActivity_.class);
    // The stack builder object will contain an artificial back stack for the
    // started Activity.
    // This ensures that navigating backward from the Activity leads out of
    // your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(ImportAuthorsActivity_.class);
    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(resultPendingIntent);

    for (String authUrl : authorsList) {
        try {
            if (shouldCancel) {
                //Make sure to cancel it here as well
                notificationManager.cancel(NOTIFICATION_ID);
                break;
            }
            SiteStrategy strategy = SiteDetector.chooseStrategy(authUrl, helper);
            if (strategy == null) {
                this.importProgress.importFail(authUrl);
            } else {
                int returnMsg = strategy.addAuthorForUrl(authUrl);
                if (returnMsg == -1) {
                    this.importProgress.importSuccess();
                } else {
                    this.importProgress.importFail(authUrl);
                }
            }

            if (shouldCancel) {
                //Make sure to cancel it here as well
                notificationManager.cancel(NOTIFICATION_ID);
                break;
            }
            EventBus.getDefault().post(new ImportUpdates(new ImportProgress(this.importProgress)));
            mBuilder.setContentText(getResources().getString(R.string.notification_import_progress,
                    importProgress.getTotalProcessed(), importProgress.getTotalAuthors())).setAutoCancel(false)
                    .setProgress(importProgress.getTotalAuthors(), importProgress.getTotalProcessed(), false);
            notificationManager.notify(NOTIFICATION_ID, mBuilder.build());
            //Sleep for 5 seconds to avoid ban
            Thread.sleep(5000);

            if (!shouldCancel) {
                EventBus.getDefault().post(new ImportUpdates(this.importProgress));
            }
        } catch (InterruptedException e) {
            LOGW(TAG, "Importing was forcibly stopped", e);
        }
    }
    if (!shouldCancel) {
        Intent finishIntent = HomeActivity_.intent(this).authorsProcessed(importProgress.getTotalAuthors())
                .authorsSuccessfullyImported(importProgress.getSuccessfullyImported()).get();
        // The stack builder object will contain an artificial back stack for the
        // started Activity.
        // This ensures that navigating backward from the Activity leads out of
        // your application to the Home screen.
        stackBuilder = TaskStackBuilder.create(this);
        // Adds the back stack for the Intent (but not the Intent itself)
        stackBuilder.addParentStack(HomeActivity_.class);
        // Adds the Intent that starts the Activity to the top of the stack
        stackBuilder.addNextIntent(finishIntent);

        BackupManager bm = new BackupManager(this);
        bm.dataChanged();

        AnalyticsHelper.getInstance().sendEvent(Constants.GA_ADMIN_CATEGORY, Constants.GA_EVENT_AUTHOR_IMPORT,
                Constants.GA_EVENT_IMPORT_COMPLETE, importProgress.getTotalAuthors());

        mBuilder.setProgress(0, 0, false).setOngoing(false).setAutoCancel(true)
                .setContentText(getResources().getString(R.string.notification_import_complete))
                .setContentIntent(stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT));
        notificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    }
}

From source file:com.andrada.sitracker.ui.fragment.AuthorsFragment.java

@Override
public boolean onActionItemClicked(@NotNull ActionMode mode, @NotNull MenuItem item) {
    mode.finish();/*from   ww  w .ja  v a2 s.c om*/
    if (item.getItemId() == R.id.action_remove) {
        AnalyticsHelper.getInstance().sendEvent(Constants.GA_ADMIN_CATEGORY, Constants.GA_EVENT_AUTHOR_REMOVED,
                Constants.GA_EVENT_AUTHOR_REMOVED, (long) mSelectedAuthors.size());

        //This stuff is on background thread
        adapter.removeAuthors(mSelectedAuthors);
        return true;
    } else if (item.getItemId() == R.id.action_mark_read) {
        adapter.markAuthorsRead(mSelectedAuthors);
        AnalyticsHelper.getInstance().sendEvent(Constants.GA_ADMIN_CATEGORY,
                Constants.GA_EVENT_AUTHOR_MANUAL_READ, Constants.GA_EVENT_AUTHOR_MANUAL_READ,
                (long) mSelectedAuthors.size());

        BackupManager bm = new BackupManager(getActivity());
        bm.dataChanged();
        return true;
    } else if (item.getItemId() == R.id.action_open_authors_browser) {
        for (int i = 0; i < adapter.getCount(); i++) {
            if (mSelectedAuthors.contains(adapter.getItemId(i))) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(((Author) adapter.getItem(i)).getUrl()));
                getActivity().startActivity(intent);
            }
        }
        return true;
    }
    return false;
}

From source file:com.zns.comicdroid.activity.Comics.java

@Override
public void onDialogPositiveClick(String oldName, String newName) {
    switch (mViewType) {
    case VIEWTYPE_AUTHOR:
        getDBHelper().renameAuthor(oldName, newName);
        break;//from   w ww. j  av  a  2 s.c o  m
    case VIEWTYPE_PUBLISHER:
        getDBHelper().renamePublisher(oldName, newName);
        break;
    case VIEWTYPE_ILLUSTRATOR:
        getDBHelper().renameIllustrator(oldName, newName);
        break;
    }
    mTvHeading.setText(newName);
    //Backup
    BackupManager m = new BackupManager(this);
    m.dataChanged();
}