當前位置: 首頁>>代碼示例>>Java>>正文


Java SharedPreferences.getStringSet方法代碼示例

本文整理匯總了Java中android.content.SharedPreferences.getStringSet方法的典型用法代碼示例。如果您正苦於以下問題:Java SharedPreferences.getStringSet方法的具體用法?Java SharedPreferences.getStringSet怎麽用?Java SharedPreferences.getStringSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.SharedPreferences的用法示例。


在下文中一共展示了SharedPreferences.getStringSet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: recreateAgents

import android.content.SharedPreferences; //導入方法依賴的package包/類
private void recreateAgents(SharedPreferences settings) {
    Message request = Message.obtain();
    request.what = Environment.RECREATE_AGENTS;
    request.replyTo = replyMessenger;

    Bundle bundle = new Bundle();

    HashSet<String> agentNamesFromActivity = (HashSet<String>)
            settings.getStringSet(ACTIVITY_NAME, new HashSet<String>());
    bundle.putSerializable(AGENT_NAMES, agentNamesFromActivity);

    request.setData(bundle);

    try {
        requestMessenger.send(request);
    } catch (RemoteException ex) {
        ex.printStackTrace();
    }
}
 
開發者ID:kflauri2312lffds,項目名稱:Android_watch_magpie,代碼行數:20,代碼來源:MagpieActivityWatch.java

示例2: saveKeyHistory

import android.content.SharedPreferences; //導入方法依賴的package包/類
/**
 * 將搜索有記錄的 關鍵字 存起來(訂單搜索界麵 外銷發票號 模糊搜索的曆史記錄)
 *
 * @param keyword
 */
private void saveKeyHistory(String keyword) {
    // 存入進行搜索過的關鍵字
    SharedPreferences searchHistorySp = MyApplication_.getInstance().getSearchHistorySp();
    Set<String> search_history = searchHistorySp.getStringSet(AppDelegate.HISTORY_SALE_INVOICE_ACCOUNT_SEARCH, null);
    if (search_history == null) {
        Set<String> newSet = new TreeSet<>();
        newSet.add(keyword);
        searchHistorySp.edit().putStringSet(AppDelegate.HISTORY_SALE_INVOICE_ACCOUNT_SEARCH, newSet).commit();
    } else {
        Set<String> sets = new TreeSet<>();
        String[] strings = search_history.toArray(new String[]{});
        for (int i = 0; i < strings.length; i++) {
            sets.add(strings[i]);
        }
        sets.add(keyword);
        searchHistorySp.edit().putStringSet(AppDelegate.HISTORY_SALE_INVOICE_ACCOUNT_SEARCH, sets).commit();
    }
}
 
開發者ID:jpaijh,項目名稱:TYT,代碼行數:24,代碼來源:T_MyFund_AccountGeneralFragment.java

示例3: onNotificationsReceived

import android.content.SharedPreferences; //導入方法依賴的package包/類
private void onNotificationsReceived(List<Notification> notificationList) {
    SharedPreferences notificationsPreferences = context.getSharedPreferences(
            "Notifications", Context.MODE_PRIVATE);
    //make a copy of the string set, the returned instance should not be modified
    Set<String> currentIds = new HashSet<>(notificationsPreferences.getStringSet(
            "current_ids", Collections.emptySet()));
    for (Notification notification : notificationList) {
        String id = notification.id;
        if (!currentIds.contains(id)) {
            currentIds.add(id);
            NotificationManager.make(context, NOTIFY_ID, notification);
        }
    }
    notificationsPreferences.edit()
            .putStringSet("current_ids", currentIds)
            .apply();
}
 
開發者ID:Vavassor,項目名稱:Tusky,代碼行數:18,代碼來源:NotificationPullJobCreator.java

示例4: removeFromInstallQueue

import android.content.SharedPreferences; //導入方法依賴的package包/類
public static void removeFromInstallQueue(Context context, HashSet<String> packageNames,
        UserHandleCompat user) {
    if (packageNames.isEmpty()) {
        return;
    }
    SharedPreferences sp = Utilities.getPrefs(context);
    synchronized(sLock) {
        Set<String> strings = sp.getStringSet(APPS_PENDING_INSTALL, null);
        if (DBG) {
            Log.d(TAG, "APPS_PENDING_INSTALL: " + strings
                    + ", removing packages: " + packageNames);
        }
        if (strings != null) {
            Set<String> newStrings = new HashSet<String>(strings);
            Iterator<String> newStringsIter = newStrings.iterator();
            while (newStringsIter.hasNext()) {
                String encoded = newStringsIter.next();
                PendingInstallShortcutInfo info = decode(encoded, context);
                if (info == null || (packageNames.contains(info.getTargetPackage())
                        && user.equals(info.user))) {
                    newStringsIter.remove();
                }
            }
            sp.edit().putStringSet(APPS_PENDING_INSTALL, newStrings).apply();
        }
    }
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:28,代碼來源:InstallShortcutReceiver.java

示例5: removeFromWaitingList

import android.content.SharedPreferences; //導入方法依賴的package包/類
public static void removeFromWaitingList(UQI uqi, Set<String> fileNamesToRemove) {
    synchronized (dropboxWaitingListMutex) {
        SharedPreferences pref = uqi.getContext().getApplicationContext().getSharedPreferences(Consts.LIB_TAG, Context.MODE_PRIVATE);
        Set<String> waitingList = pref.getStringSet(DROPBOX_WAITING_LIST, new HashSet<String>());
        waitingList.removeAll(fileNamesToRemove);
        SharedPreferences.Editor editor = pref.edit();
        editor.clear();
        editor.putStringSet(DROPBOX_WAITING_LIST, waitingList);
        editor.apply();
        Logging.debug(LOG_TAG + "Removed files from waiting list: " + fileNamesToRemove);
    }
}
 
開發者ID:PrivacyStreams,項目名稱:PrivacyStreams,代碼行數:13,代碼來源:DropboxUtils.java

示例6: onServiceConnected

import android.content.SharedPreferences; //導入方法依賴的package包/類
@Override
public void onServiceConnected(ComponentName name, IBinder binder) {
    requestMessenger = new Messenger(binder);

    SharedPreferences settings = getSharedPreferences(MagpieService.MAGPIE_PREFS, MODE_PRIVATE);
    Set<String> agentNames = settings.getStringSet(ACTIVITY_NAME, new HashSet<String>());

    if (agentNames.isEmpty()) {
        onEnvironmentConnected();
    } else {
        recreateAgents(settings);
    }
}
 
開發者ID:kflauri2312lffds,項目名稱:Android_watch_magpie,代碼行數:14,代碼來源:MagpieActivityWatch.java

示例7: getPinnedProperties

import android.content.SharedPreferences; //導入方法依賴的package包/類
public static HashSet<Integer> getPinnedProperties(SharedPreferences pref) {
    Set<String> stringVals = pref.getStringSet(prefKeyPinnedProperties, new HashSet<>());
    HashSet<Integer> result = new HashSet<>();
    for (String s : stringVals)
        result.add(Integer.parseInt(s));
    return result;
}
 
開發者ID:ericberman,項目名稱:MyFlightbookAndroid,代碼行數:8,代碼來源:CustomPropertyType.java

示例8: removePinnedProperty

import android.content.SharedPreferences; //導入方法依賴的package包/類
public static void removePinnedProperty(SharedPreferences pref, int id) {
    Set<String> stringVals = pref.getStringSet(prefKeyPinnedProperties, new HashSet<>());

    String sRemove = String.format(Locale.US, "%d", id);
    if (!stringVals.contains(sRemove))
        return;

    // Can't modify the returned set; need to create a new one.
    HashSet<String> newSet = new HashSet<>(stringVals);
    newSet.remove(sRemove);

    SharedPreferences.Editor e = pref.edit();
    e.putStringSet(prefKeyPinnedProperties, newSet);
    e.apply();
}
 
開發者ID:ericberman,項目名稱:MyFlightbookAndroid,代碼行數:16,代碼來源:CustomPropertyType.java

示例9: shouldStartService

import android.content.SharedPreferences; //導入方法依賴的package包/類
private static boolean shouldStartService(Context context, int mediaType, int tabId) {
    if (mediaType != MEDIATYPE_NO_MEDIA) return true;
    SharedPreferences sharedPreferences =
            ContextUtils.getAppSharedPreferences();
    Set<String> notificationIds =
            sharedPreferences.getStringSet(WEBRTC_NOTIFICATION_IDS, null);
    if (notificationIds != null
            && !notificationIds.isEmpty()
            && notificationIds.contains(String.valueOf(tabId))) {
        return true;
    }
    return false;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:14,代碼來源:MediaCaptureNotificationService.java

示例10: onCreate

import android.content.SharedPreferences; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // 取得地圖物件
    setContentView(R.layout.activity_maps);
    mLayoutContainer = (ViewGroup) findViewById(R.id.layout_container);
    mMapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
    mMapFragment.getMapAsync(this);

    // For tracking, Create an instance of GoogleAPIClient and LocationRequest.
    configGoogleApiClient();
    configLocationRequest();

    // Buttons on map
    mSwitchBtn = (Button) findViewById(R.id.btn_switch);
    mTrackingBtn = (Button) findViewById(R.id.btn_tracking);
    mPickTilesBtn = (Button) findViewById(R.id.btn_pick_tiles);
    mGpxManagerBtn = (Button) findViewById(R.id.btn_gpx_files_list);
    mPoiSearchBtn = (Button) findViewById(R.id.btn_search);

    mBtnsSet.add(mPickTilesBtn);
    mBtnsSet.add(mTrackingBtn);
    mBtnsSet.add(mGpxManagerBtn);
    mBtnsSet.add(mPoiSearchBtn);

    mSwitchBtn.setOnClickListener(this);
    for (View btn : mBtnsSet) {
        btn.setOnClickListener(this);
    }

    // Add center cross into main map
    mCrossSet.add(MAP_CODE_MAIN, (ImageView) findViewById(R.id.cross));

    // 取得ActionBar
    mActionBar = getSupportActionBar();

    // 還原各項設定
    SharedPreferences prefs = getSharedPreferences(PREFS_NAME, 0);
    // 檢查是否紀錄航跡中
    mTrackingBtn.setSelected(prefs.getBoolean("isTracking", false));
    if (mTrackingBtn.isSelected()) {
        // bind TrackingService
        Intent bindIntent = new Intent(this, TrackingService.class);
        bindService(bindIntent, this, BIND_AUTO_CREATE);
    }

    // 取得上次相機位置
    LatLng lastTarget = new LatLng(prefs.getFloat(
            "cameraLat", (float) TAIWAN_CENTER.latitude),
            prefs.getFloat("cameraLon", (float) TAIWAN_CENTER.longitude));
    Float lastZoom = prefs.getFloat("cameraZoom", STARTING_ZOOM);
    lastCameraPosition = new CameraPosition(lastTarget, lastZoom, 0, 0);

    // 取得已開啟的GPX檔案
    mGpxFileList = prefs.getStringSet("gpxFiles", mGpxFileList);

    // 取得POI檔案
    poiFile = prefs.getString("poiFile", null);

    // 取得離線地圖檔案
    mapFile = prefs.getString("mapFile", null);
    themeFile = prefs.getString("themeFile", null);

    // 還原座標表示設定
    CoorSysList.coorSetting = prefs.getInt("coorSetting", COOR_WGS84_D);
}
 
開發者ID:typebrook,項目名稱:FiveMinsMore,代碼行數:68,代碼來源:MapsActivity.java

示例11: getStringSet

import android.content.SharedPreferences; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public static Set<String> getStringSet(String name, Set<String> defaultValue){
    SharedPreferences sp=getSP(name);
    if (sp==null)return defaultValue;
    return sp.getStringSet(name, defaultValue);
}
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:7,代碼來源:SPHelperImpl.java

示例12: getArrayPref

import android.content.SharedPreferences; //導入方法依賴的package包/類
public static Set<String> getArrayPref(Context context, String name) {
    SharedPreferences prefs = context.getSharedPreferences(
            "com.luca89.search_history", Context.MODE_PRIVATE);
    return prefs.getStringSet(name, new HashSet<String>());
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:6,代碼來源:MusicUtils.java

示例13: isFollowing

import android.content.SharedPreferences; //導入方法依賴的package包/類
static boolean isFollowing(Context context, String username) {
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    Set<String> followedStreamers = settings.getStringSet(followingKeyName, new HashSet<String>());

    return followedStreamers.contains(username);
}
 
開發者ID:invghost,項目名稱:NeoStream,代碼行數:7,代碼來源:UserData.java

示例14: getFavoriteContacts

import android.content.SharedPreferences; //導入方法依賴的package包/類
/** Restituisce l'insieme dei numeri di contatti preferiti dell'utente. */
public static Set<String> getFavoriteContacts(Context context) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    return sharedPreferences.getStringSet(SettingsActivity.PREFERENCES_CONTACTS_KEY, new HashSet<String>());
}
 
開發者ID:gvinciguerra,項目名稱:custode,代碼行數:6,代碼來源:CustodeUtils.java

示例15: handleDisturbanceNotification

import android.content.SharedPreferences; //導入方法依賴的package包/類
private void handleDisturbanceNotification(String network, String line,
                                           String id, String status, boolean downtime,
                                           long msgtime) {
    Log.d("MainService", "handleDisturbanceNotification");
    SharedPreferences sharedPref = getSharedPreferences("notifsettings", MODE_PRIVATE);
    Set<String> linePref = sharedPref.getStringSet("pref_notifs_lines", null);

    Network snetwork;
    synchronized (lock) {
        if (!networks.containsKey(network)) {
            return;
        }
        snetwork = networks.get(network);
    }
    Line sline = snetwork.getLine(line);
    if (sline == null) {
        return;
    }

    if (downtime) {
        lineStatusCache.markLineAsDown(sline, new Date(msgtime));
    } else {
        lineStatusCache.markLineAsUp(sline);
    }

    if (linePref != null && !linePref.contains(line)) {
        // notifications disabled for this line
        return;
    }

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    if (!downtime && !sharedPref.getBoolean("pref_notifs_service_resumed", true)) {
        // notifications for normal service resumed disabled
        notificationManager.cancel(id.hashCode());
        return;
    }

    Realm realm = Realm.getDefaultInstance();
    for (NotificationRule rule : realm.where(NotificationRule.class).findAll()) {
        if (rule.isEnabled() && rule.applies(new Date(msgtime))) {
            realm.close();
            return;
        }
    }
    realm.close();

    Intent intent = new Intent(this, MainActivity.class);
    intent.putExtra(MainActivity.EXTRA_INITIAL_FRAGMENT, "nav_disturbances");
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);

    String title = String.format(getString(R.string.notif_disturbance_title), sline.getName());

    NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
    bigTextStyle.setBigContentTitle(title);
    bigTextStyle.bigText(status);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setStyle(bigTextStyle)
            .setSmallIcon(R.drawable.ic_disturbance_notif)
            .setColor(sline.getColor())
            .setContentTitle(title)
            .setContentText(status)
            .setAutoCancel(true)
            .setWhen(msgtime)
            .setSound(Uri.parse(sharedPref.getString(downtime ? "pref_notifs_ringtone" : "pref_notifs_regularization_ringtone", "content://settings/system/notification_sound")))
            .setVisibility(Notification.VISIBILITY_PUBLIC)
            .setContentIntent(pendingIntent);

    if (sharedPref.getBoolean(downtime ? "pref_notifs_vibrate" : "pref_notifs_regularization_vibrate", false)) {
        notificationBuilder.setVibrate(new long[]{0, 100, 100, 150, 150, 200});
    } else {
        notificationBuilder.setVibrate(new long[]{0l});
    }

    notificationManager.notify(id.hashCode(), notificationBuilder.build());
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:79,代碼來源:MainService.java


注:本文中的android.content.SharedPreferences.getStringSet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。