本文整理汇总了Java中android.app.backup.BackupManager.dataChanged方法的典型用法代码示例。如果您正苦于以下问题:Java BackupManager.dataChanged方法的具体用法?Java BackupManager.dataChanged怎么用?Java BackupManager.dataChanged使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.backup.BackupManager
的用法示例。
在下文中一共展示了BackupManager.dataChanged方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStop
import android.app.backup.BackupManager; //导入方法依赖的package包/类
@Override
public void onStop() {
// If something changed, tell WikiService to kick back in. Don't
// worry; if WikiService isn't paused, this won't do anything, and
// if it's stopped for any other reason, it'll stop again when this
// comes in.
if(mHasChanged) {
mHasChanged = false;
Intent i = new Intent(getActivity(), WikiService.class);
i.putExtra(QueueService.COMMAND_EXTRA, QueueService.COMMAND_RESUME);
getActivity().startService(i);
}
BackupManager bm = new BackupManager(getActivity());
bm.dataChanged();
super.onStop();
}
示例2: setNightMode
import android.app.backup.BackupManager; //导入方法依赖的package包/类
/**
* <p>
* Sets whether or not the app is in night mode.
* </p>
*
* <p>
* <b>NOTE:</b> If the state of night mode changes, <b>the Activity WILL be
* recreated</b>, as that's the only way you can change themes on-the-fly.
* Make sure you've done whatever you need to BEFORE calling this, as there
* is NO guarantee execution will meaningfully continue past this!
* </p>
*
* @param night true to be night, false to be not night
*/
protected void setNightMode(boolean night) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
// Remember, ONLY act on this if this changed at all!
if(prefs.getBoolean(GHDConstants.PREF_NIGHT_MODE, false) != night) {
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean(GHDConstants.PREF_NIGHT_MODE, night);
edit.apply();
BackupManager bm = new BackupManager(this);
bm.dataChanged();
recreate();
}
}
示例3: updateLastGraticule
import android.app.backup.BackupManager; //导入方法依赖的package包/类
private void updateLastGraticule(@NonNull Info info) {
// This'll just stash the last Graticule away in preferences so we can
// start with the last-used one if preferences demand it as such.
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean(GHDConstants.PREF_DEFAULT_GRATICULE_GLOBALHASH, info.isGlobalHash());
Graticule g = info.getGraticule();
if(g != null) {
edit.putString(GHDConstants.PREF_DEFAULT_GRATICULE_LATITUDE, g.getLatitudeString(true));
edit.putString(GHDConstants.PREF_DEFAULT_GRATICULE_LONGITUDE, g.getLongitudeString(true));
}
edit.apply();
BackupManager bm = new BackupManager(this);
bm.dataChanged();
}
示例4: storeKnownLocations
import android.app.backup.BackupManager; //导入方法依赖的package包/类
/**
* Stores a bunch of KnownLocations to preferences. Note that this <b>replaces</b>
* all currently-stored KnownLocations.
*
* @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();
}
示例5: getUserID
import android.app.backup.BackupManager; //导入方法依赖的package包/类
public static String getUserID(Context context) {
if (uniqueID == null) {
SharedPreferences sharedPrefs = context.getSharedPreferences(SimpleBackupAgent.PREFS, Context.MODE_PRIVATE);
uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null);
if (uniqueID == null) {
uniqueID = UUID.randomUUID().toString();
SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putString(PREF_UNIQUE_ID, uniqueID);
editor.commit();
//backup the changes
BackupManager mBackupManager = new BackupManager(context);
mBackupManager.dataChanged();
}
}
return uniqueID;
}
示例6: update
import android.app.backup.BackupManager; //导入方法依赖的package包/类
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
SQLiteDatabase dbWritable = mOpenHelper.getWritableDatabase();
dbWritable.beginTransaction();
int count = dbWritable.update(getTableName(uri), values, selection, selectionArgs);
dbWritable.setTransactionSuccessful();
dbWritable.endTransaction();
// Log.i(TAG, "Updated rows: " + count);
if (count > 0) {
BackupManager.dataChanged(getContext().getPackageName());
}
return count;
}
示例7: updateLocale
import android.app.backup.BackupManager; //导入方法依赖的package包/类
/**
* Requests the system to update the system locale. Note that the system looks halted
* for a while during the Locale migration, so the caller need to take care of it.
* <p/>
* Requires android.permission.CHANGE_CONFIGURATION
*/
public static void updateLocale(Locale locale) {
try {
IActivityManager am = ActivityManagerNative.getDefault();
Configuration config = am.getConfiguration();
// Will set userSetLocale to indicate this isn't some passing default - the user
// wants this remembered
config.setLocale(locale);
am.updateConfiguration(config);
// Trigger the dirty bit for the Settings Provider.
BackupManager.dataChanged("com.android.providers.settings");
} catch (RemoteException e) {
// Intentionally left blank
}
}
示例8: onSharedPreferenceChanged
import android.app.backup.BackupManager; //导入方法依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
// Ask Backup
BackupManager.dataChanged(getPackageName());
// Recompute Change Sumaries
Log.d(TAG, "### onSharedPreferenceChanged key : " + key);
Preference pref = findPreference(key);
Log.d(TAG, "### onSharedPreferenceChanged findPreference : " + pref);
setSummary(this, pref);
// Tracker
// GeoPingApplication.getInstance().tracker().trackPageView("/Pref/" +
// key);
Tracker tracker = tracker = GeoPingApplication.getGeoPingApplication(this).getTracker();
tracker.send(new HitBuilders.EventBuilder()//
.setCategory("ui_pref") // Category
.setAction("changed") // Action
.setLabel(key) // Label
.build());
}
示例9: insert
import android.app.backup.BackupManager; //导入方法依赖的package包/类
@Override
public Uri insert(Uri uri, ContentValues values) {
switch (sURIMatcher.match(uri)) {
case PERSONS:
long personId = personDatabase.insertEntity(values);
Uri personUri = null;
if (personId > -1) {
personUri = Uri.withAppendedPath(Constants.CONTENT_URI, String.valueOf(personId));
getContext().getContentResolver().notifyChange(uri, null);
// Backup
BackupManager.dataChanged(getContext().getPackageName());
}
return personUri;
default:
throw new IllegalArgumentException("Unknown Uri: " + uri);
}
}
示例10: delete
import android.app.backup.BackupManager; //导入方法依赖的package包/类
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
int count = 0;
switch (sURIMatcher.match(uri)) {
case PERSON_ID:
String entityId = uri.getLastPathSegment();
String[] args = new String[] { entityId };
count = personDatabase.deleteEntity(PersonColumns.SELECT_BY_ENTITY_ID, args);
break;
case PERSONS:
count = personDatabase.deleteEntity(selection, selectionArgs);
break;
default:
throw new IllegalArgumentException("Unknown Uri: " + uri);
}
if (count > 0) {
getContext().getContentResolver().notifyChange(uri, null);
// Backup
BackupManager.dataChanged(getContext().getPackageName());
}
return count;
}
示例11: update
import android.app.backup.BackupManager; //导入方法依赖的package包/类
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
int count = 0;
switch (sURIMatcher.match(uri)) {
case PERSON_ID:
String entityId = uri.getLastPathSegment();
String[] args = new String[] { entityId };
count = personDatabase.updateEntity(values, PersonColumns.SELECT_BY_ENTITY_ID, args);
break;
case PERSONS:
count = personDatabase.updateEntity(values, selection, selectionArgs);
break;
default:
throw new IllegalArgumentException("Unknown Uri: " + uri);
}
if (count > 0) {
getContext().getContentResolver().notifyChange(uri, null);
// Backup
BackupManager.dataChanged(getContext().getPackageName());
}
return count;
}
示例12: insert
import android.app.backup.BackupManager; //导入方法依赖的package包/类
@Override
public Uri insert(Uri uri, ContentValues values) {
switch (sURIMatcher.match(uri)) {
case PAIRINGS:
long pairingId = pairingDatabase.insertEntity(values);
Uri pairingUri = null;
if (pairingId > -1) {
pairingUri = Uri.withAppendedPath(Constants.CONTENT_URI, String.valueOf(pairingId));
getContext().getContentResolver().notifyChange(uri, null);
Log.i(TAG, String.format("Insert Pairing %s : %s", pairingUri, values));
// Backup
BackupManager.dataChanged(getContext().getPackageName());
}
return pairingUri;
default:
throw new IllegalArgumentException("Unknown Uri: " + uri);
}
}
示例13: delete
import android.app.backup.BackupManager; //导入方法依赖的package包/类
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
int count = 0;
switch (sURIMatcher.match(uri)) {
case PAIRING_ID:
String entityId = uri.getLastPathSegment();
String[] args = new String[] { entityId };
count = pairingDatabase.deleteEntity(PairingColumns.SELECT_BY_ENTITY_ID, args);
break;
case PAIRINGS:
count = pairingDatabase.deleteEntity(selection, selectionArgs);
break;
default:
throw new IllegalArgumentException("Unknown Uri: " + uri);
}
if (count > 0) {
getContext().getContentResolver().notifyChange(uri, null);
// Backup
BackupManager.dataChanged(getContext().getPackageName());
}
return count;
}
示例14: update
import android.app.backup.BackupManager; //导入方法依赖的package包/类
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
int count = 0;
switch (sURIMatcher.match(uri)) {
case PAIRING_ID:
String entityId = uri.getLastPathSegment();
String[] args = new String[] { entityId };
count = pairingDatabase.updateEntity(values, PairingColumns.SELECT_BY_ENTITY_ID, args);
break;
case PAIRINGS:
count = pairingDatabase.updateEntity(values, selection, selectionArgs);
break;
default:
throw new IllegalArgumentException("Unknown Uri: " + uri);
}
if (count > 0) {
getContext().getContentResolver().notifyChange(uri, null);
// Backup
BackupManager.dataChanged(getContext().getPackageName());
}
return count;
}
示例15: insert
import android.app.backup.BackupManager; //导入方法依赖的package包/类
@Override
public Uri insert(Uri uri, ContentValues values) {
switch (sURIMatcher.match(uri)) {
case GEOFENCES:
long geofenceId = geofenceDatabase.insertEntity(values);
Uri geofenceUri = null;
if (geofenceId > -1) {
geofenceUri = Constants.getContentUri(geofenceId);
getContext().getContentResolver().notifyChange(uri, null);
Log.i(TAG, String.format("Insert GeoFence %s : %s", geofenceUri, values));
// Backup
BackupManager.dataChanged(getContext().getPackageName());
}
return geofenceUri;
default:
throw new IllegalArgumentException("Unknown insert Uri: " + uri);
}
}