当前位置: 首页>>代码示例>>Java>>正文


Java BackupManager类代码示例

本文整理汇总了Java中android.app.backup.BackupManager的典型用法代码示例。如果您正苦于以下问题:Java BackupManager类的具体用法?Java BackupManager怎么用?Java BackupManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BackupManager类属于android.app.backup包,在下文中一共展示了BackupManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.app.backup.BackupManager; //导入依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
            final SubScreenFragment fragment = SubScreenFragment.this;
            final Context context = fragment.getActivity();
            if (context == null || fragment.getPreferenceScreen() == null) {
                final String tag = fragment.getClass().getSimpleName();
                // TODO: Introduce a static function to register this class and ensure that
                // onCreate must be called before "onSharedPreferenceChanged" is called.
                Log.w(tag, "onSharedPreferenceChanged called before activity starts.");
                return;
            }
            new BackupManager(context).dataChanged();
            fragment.onSharedPreferenceChanged(prefs, key);
        }
    };
    getSharedPreferences().registerOnSharedPreferenceChangeListener(
            mSharedPreferenceChangeListener);
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:23,代码来源:SubScreenFragment.java

示例2: onCreate

import android.app.backup.BackupManager; //导入依赖的package包/类
/** Set up the activity and populate its UI from the persistent data. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /** Establish the activity's UI */
    setContentView(R.layout.backup_restore);

    /** Once the UI has been inflated, cache the controls for later */
    mFillingGroup = (RadioGroup) findViewById(R.id.filling_group);
    mAddMayoCheckbox = (CheckBox) findViewById(R.id.mayo);
    mAddTomatoCheckbox = (CheckBox) findViewById(R.id.tomato);

    /** Set up our file bookkeeping */
    mDataFile = new File(getFilesDir(), BackupRestoreActivity.DATA_FILE_NAME);

    /** It is handy to keep a BackupManager cached */
    mBackupManager = new BackupManager(this);

    /**
     * Finally, build the UI from the persistent store
     */
    populateUI();
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:25,代码来源:BackupRestoreActivity.java

示例3: setInternalActiveExtensions

import android.app.backup.BackupManager; //导入依赖的package包/类
/**
 * Replaces the set of active extensions with the given list.
 */
public void setInternalActiveExtensions(List<ComponentName> extensions) {
    StringBuilder sb = new StringBuilder();

    for (ComponentName extension : extensions) {
        if (sb.length() > 0) {
            sb.append(",");
        }
        sb.append(extension.flattenToString());
    }

    mDefaultPreferences.edit()
            .putString(PREF_ACTIVE_EXTENSIONS, sb.toString())
            .apply();
    new BackupManager(mApplicationContext).dataChanged();

    mInternalActiveExtensions.clear();
    mInternalActiveExtensions.addAll(extensions);
    setActiveExtensions(getActiveExtensionNames());
}
 
开发者ID:mridang,项目名称:dashbar,代码行数:23,代码来源:ExtensionManager.java

示例4: onSharedPreferenceChanged

import android.app.backup.BackupManager; //导入依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
    new BackupManager(getActivity()).dataChanged();

    // Potentially enable/disable the launcher activity if the settings button
    // preference has changed.
    if (isAdded() && AppearanceConfig.PREF_SETTINGS_BUTTON.equals(key)) {
        boolean enableLauncher = AppearanceConfig.PREF_SETTINGS_BUTTON_IN_LAUNCHER.equals(
                sp.getString(AppearanceConfig.PREF_SETTINGS_BUTTON, null));
        getActivity().getPackageManager().setComponentEnabledSetting(
                new ComponentName(
                        getActivity().getPackageName(),
                        ConfigurationActivity.LAUNCHER_ACTIVITY_NAME),
                enableLauncher
                        ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                        : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
    }
}
 
开发者ID:mridang,项目名称:dashbar,代码行数:20,代码来源:ConfigureAdvancedFragment.java

示例5: 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();
}
 
开发者ID:CaptainSpam,项目名称:geohashdroid,代码行数:19,代码来源:PreferencesScreen.java

示例6: 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();
    }
}
 
开发者ID:CaptainSpam,项目名称:geohashdroid,代码行数:30,代码来源:BaseGHDThemeActivity.java

示例7: 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();
}
 
开发者ID:CaptainSpam,项目名称:geohashdroid,代码行数:20,代码来源:CentralMap.java

示例8: 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();
}
 
开发者ID:CaptainSpam,项目名称:geohashdroid,代码行数:25,代码来源:KnownLocation.java

示例9: onSharedPreferenceChanged

import android.app.backup.BackupManager; //导入依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
    new BackupManager(getActivity()).dataChanged();

    // Potentially enable/disable the launcher activity if the settings button
    // preference has changed.
    final String launcherIntentKey = getString(R.string.pref_key_launcher_intent);
    if (isAdded() && launcherIntentKey.equals(s)) {

        final boolean hideLauncher = sharedPreferences.getBoolean(launcherIntentKey, false);
        getActivity().getPackageManager().setComponentEnabledSetting(
                new ComponentName(
                        getActivity().getPackageName(),
                        LAUNCHER_ACTIVITY_NAME),
                hideLauncher
                        ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED
                        : PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                PackageManager.DONT_KILL_APP);
    }
}
 
开发者ID:tasomaniac,项目名称:MuzeiEarthView,代码行数:21,代码来源:SettingsFragment.java

示例10: onSharedPreferenceChanged

import android.app.backup.BackupManager; //导入依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
  new BackupManager(getActivity()).dataChanged();

  // Potentially enable/disable the launcher activity if the settings button
  // preference has changed.
  final String launcherIntentKey = getString(R.string.pref_key_launcher_intent);
  if (isAdded() && launcherIntentKey.equals(s)) {

    final boolean hideLauncher = sharedPreferences.getBoolean(launcherIntentKey, false);
    packageManager.setComponentEnabledSetting(
        new ComponentName(
            getActivity().getPackageName(),
            LAUNCHER_ACTIVITY_NAME),
        hideLauncher
            ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED
            : PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
        PackageManager.DONT_KILL_APP);
  }
}
 
开发者ID:tasomaniac,项目名称:SeriesGuideToPlex,代码行数:21,代码来源:SettingsFragment.java

示例11: 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;
}
 
开发者ID:thomashaertel,项目名称:android-device-identification,代码行数:19,代码来源:UserIdentifier.java

示例12: onSharedPreferenceChanged

import android.app.backup.BackupManager; //导入依赖的package包/类
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    LOGI(TAG, "onSharedPreferenceChanged(" + key + ')');
    Context context = getApplicationContext();
    if (null != context) {
        (new BackupManager(context)).dataChanged();
    }

    if (Constants.PREF_VOLUME_PANEL.equals(key)) {
        // TRACK: what theme is being used.
        String panel = sharedPreferences.getString(key, StatusBarVolumePanel.TAG);
        VolumeAccessibilityService.VolumePanelChangeEvent event =
                new VolumeAccessibilityService.VolumePanelChangeEvent(panel, Utils.supportsMediaPlayback(panel));
        onVolumePanelChangeEvent(event);
    } else if (Constants.PREF_REPORTING.equals(key)) {
        // TRACK: when the user opts out of being tracked.
    }
}
 
开发者ID:Tombarr,项目名称:Noyze,代码行数:18,代码来源:ConfigurationActivity.java

示例13: delete

import android.app.backup.BackupManager; //导入依赖的package包/类
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
    ContentConstants.ProtocolURLs vrUrl = convertURIToProtocolURL(uri);
    int count = 0;
    switch (vrUrl) {
        case URLProtocol:
            count = db.getWritableDatabase().delete(Protocol.TABLE_NAME, selection, selectionArgs);
            if (count > 0) {
                new BackupManager(getContext()).dataChanged();
            }
            break;
    }
    getContext().getContentResolver().notifyChange(uri, null);

    // Returns the number of rows deleted.
    return count;
}
 
开发者ID:rafaelcoutinho,项目名称:cowbird,代码行数:18,代码来源:ProtocolDBContentProvider.java

示例14: insert

import android.app.backup.BackupManager; //导入依赖的package包/类
@Override
public Uri insert(Uri uri, ContentValues values) {
    ContentConstants.ProtocolURLs vrUrl = convertURIToProtocolURL(uri);
    long rowId = -1;
    switch (vrUrl) {
        case URLProtocol:
            rowId = db.getWritableDatabase().insert(Protocol.TABLE_NAME, null, values);
            new BackupManager(getContext()).dataChanged();
            break;
        default:
            throw new SQLiteConstraintException("Failed to switch insert protocol " + uri);

    }

    // If the insert succeeded, the row ID exists.
    if (rowId > 0) {
        // Creates a URI with the note ID pattern and the new row ID appended to it.
        Uri noteUri = ContentConstants.getUriFor(vrUrl, rowId);

        // Notifies observers registered against this provider that the data changed.
        getContext().getContentResolver().notifyChange(noteUri, null);
        return noteUri;
    } else {
        throw new SQLiteConstraintException("Failed to insert row into " + uri);
    }
}
 
开发者ID:rafaelcoutinho,项目名称:cowbird,代码行数:27,代码来源:ProtocolDBContentProvider.java

示例15: update

import android.app.backup.BackupManager; //导入依赖的package包/类
@Override
public int update(Uri uri, ContentValues values, String selection,
                  String[] selectionArgs) {
    int count = 0;
    ContentConstants.ProtocolURLs vrUrl = convertURIToProtocolURL(uri);
    switch (vrUrl) {
        case URLProtocol:
            SQLiteDatabase sql = db.getWritableDatabase();
            count = sql.update(Protocol.TABLE_NAME, values, selection, selectionArgs);
            if (count > 0) {
                new BackupManager(getContext()).dataChanged();
            }
            break;
    }

    getContext().getContentResolver().notifyChange(uri, null);
    return count;

}
 
开发者ID:rafaelcoutinho,项目名称:cowbird,代码行数:20,代码来源:ProtocolDBContentProvider.java


注:本文中的android.app.backup.BackupManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。