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


Java Bundle.keySet方法代碼示例

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


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

示例1: getMessage

import android.os.Bundle; //導入方法依賴的package包/類
private MyMessage getMessage(Bundle bundle){
    MyMessage message = new MyMessage();
    message.setIsScanned(0);
    for (String key : bundle.keySet()) {
        if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
            message.setNotifyId(String.valueOf(bundle.getInt(key)));
        }else if(key.equals(JPushInterface.EXTRA_ALERT)){
            message.setAlert(bundle.getString(key));
        } else if (key.equals(JPushInterface.EXTRA_MSG_ID)) {
            message.setMsgId(bundle.getString(key));
        } else if (key.equals(JPushInterface.EXTRA_ALERT_TYPE)) {
            message.setType(bundle.getString(key));
        }else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
            if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
                Log.d(TAG, "This message has no Extra data");
                continue;
            }

            try {
                JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
                Iterator<String> it =  json.keys();

                while (it.hasNext()) {
                    String myKey = it.next().toString();
                    if(myKey.equals("title")){
                        message.setTitle(json.optString(myKey));
                    }else if(myKey.equals("date")){
                        message.setDate(json.optString(myKey));
                    }

                }
            } catch (JSONException e) {
                Log.e(TAG, "Get message extra JSON error!");
            }

        }
    }
    return message;
}
 
開發者ID:ruiqiao2017,項目名稱:Renrentou,代碼行數:40,代碼來源:JpushReceiver.java

示例2: onNotificationPosted

import android.os.Bundle; //導入方法依賴的package包/類
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
    if (Log.isPrint) {
        Log.i(TAG, sbn.toString());
        Notification notification = sbn.getNotification();
        Log.i(TAG, "tickerText : " + notification.tickerText);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Bundle bundle = notification.extras;
            for (String key : bundle.keySet()) {
                Log.i(TAG, key + ": " + bundle.get(key));
            }
        }
    }
    if (self != null && notificationListener != null) {
        notificationListener.onNotificationPosted(sbn);
    }
}
 
開發者ID:jqjm,項目名稱:Liteframework,代碼行數:18,代碼來源:NotificationService.java

示例3: restoreFragments

import android.os.Bundle; //導入方法依賴的package包/類
private void restoreFragments(Bundle bundle) {
    Iterable<String> keys = bundle.keySet();
    for (String key : keys) {
        if (key.startsWith("f")) {
            // key sample "f1-2"
            int position = Integer.parseInt(key.substring(1, key.indexOf("-")));
            int viewMode = Integer.parseInt(key.substring(key.indexOf("-") + 1));
            Fragment f = mFragmentManager.getFragment(bundle, key);
            if (f != null) {
                while (mFragments.size() <= position) {
                    mFragments.add(null);
                }
                f.setMenuVisibility(false);
                setFragment(position, viewMode, f);
            } else {
                Log.w(TAG, "Bad fragment at key " + key);
            }
        }
    }
}
 
開發者ID:mocircle,項目名稱:devsuite-android,代碼行數:21,代碼來源:MultiFragmentStatePagerAdapter.java

示例4: valueSizes

import android.os.Bundle; //導入方法依賴的package包/類
/**
 * Measure the sizes of all the values in a typed {@link Bundle} when written to a
 * {@link Parcel}. Returns a map from keys to the sizes, in bytes, of the associated values in
 * the Bundle.
 *
 * @param bundle to measure
 * @return a map from keys to value sizes in bytes
 */
public static Map<String, Integer> valueSizes(@NonNull Bundle bundle) {
    Map<String, Integer> result = new HashMap<>(bundle.size());
    // We measure the size of each value by measuring the total size of the bundle before and
    // after removing that value and calculating the difference. We make a copy of the original
    // bundle so we can put all the original values back at the end. It's not possible to
    // carry out the measurements on the copy because of the way Android parcelables work
    // under the hood where certain objects are actually stored as references.
    Bundle copy = new Bundle(bundle);
    try {
        int bundleSize = sizeAsParcel(bundle);
        // Iterate over copy's keys because we're removing those of the original bundle
        for (String key : copy.keySet()) {
            bundle.remove(key);
            int newBundleSize = sizeAsParcel(bundle);
            int valueSize = bundleSize - newBundleSize;
            result.put(key, valueSize);
            bundleSize = newBundleSize;
        }
        return result;
    } finally {
        // Put everything back into original bundle
        bundle.putAll(copy);
    }
}
 
開發者ID:guardian,項目名稱:toolargetool,代碼行數:33,代碼來源:TooLargeTool.java

示例5: encodePostBody

import android.os.Bundle; //導入方法依賴的package包/類
public static String encodePostBody(Bundle bundle, String str) {
    if (bundle == null) {
        return "";
    }
    StringBuilder stringBuilder = new StringBuilder();
    int size = bundle.size();
    int i = -1;
    for (String str2 : bundle.keySet()) {
        int i2 = i + 1;
        Object obj = bundle.get(str2);
        if (obj instanceof String) {
            stringBuilder.append("Content-Disposition: form-data; name=\"" + str2 + a.e +
                    "\r\n" + "\r\n" + ((String) obj));
            if (i2 < size - 1) {
                stringBuilder.append("\r\n--" + str + "\r\n");
            }
            i = i2;
        } else {
            i = i2;
        }
    }
    return stringBuilder.toString();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:24,代碼來源:Util.java

示例6: examineIntent

import android.os.Bundle; //導入方法依賴的package包/類
/**
 * For debugging the intent extras
 *
 * @param intent containing potential extras
 */
private void examineIntent(@Nullable final Intent intent) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "examineIntent");
    }

    if (intent != null) {
        final Bundle bundle = intent.getExtras();
        if (bundle != null) {
            final Set<String> keys = bundle.keySet();
            for (final String key : keys) {
                if (DEBUG) {
                    MyLog.v(CLS_NAME, "examineIntent: " + key + " ~ " + bundle.get(key));
                }
            }
        }
    }
}
 
開發者ID:brandall76,項目名稱:Saiy-PS,代碼行數:23,代碼來源:AssistantIntentService.java

示例7: logIntent

import android.os.Bundle; //導入方法依賴的package包/類
public static void logIntent(String handleObjectSimpleName, Intent data) {
    if (data == null || data.getExtras() == null) {
        return;
    }

    log(BackFlow._TAG, "╔═══════════════════════════════════════════════════════════════════════════════════════");
    log(BackFlow._TAG, "║curr handle object:" + handleObjectSimpleName);

    Bundle bundle = data.getExtras();
    for (String key : bundle.keySet()) {
        String value = String.valueOf(bundle.get(key));
        log(BackFlow._TAG, "║" + key + ":" + value);
    }

    log(BackFlow._TAG, "╚═══════════════════════════════════════════════════════════════════════════════════════");
}
 
開發者ID:xuyt11,項目名稱:androidBackFlow,代碼行數:17,代碼來源:BackFlow.java

示例8: processIntent

import android.os.Bundle; //導入方法依賴的package包/類
private void processIntent() {
    if (getIntent().getExtras() != null) {
        Bundle extras = getIntent().getExtras();
        for (String key : extras.keySet()) {
            Utils.logError(key + " = " + extras.get(key).toString());
        }
    }

    if (getIntent().hasExtra("start_intent")) {
        Utils.getController().closeActivities();

        int notificationTarget = getIntent().getIntExtra("start_intent", -1);

        switch (notificationTarget) {
            case NotificationHandler.ID_ESSENSBONS:
                startActivity(new Intent(getApplicationContext(), EssensbonActivity.class));
                break;

            case NotificationHandler.ID_KLAUSURPLAN:
                startActivity(new Intent(getApplicationContext(), KlausurplanActivity.class));
                break;

            case NotificationHandler.ID_MESSENGER:
                startActivity(new Intent(getApplicationContext(), MessengerActivity.class));
                break;

            case NotificationHandler.ID_UMFRAGEN:
                startActivity(new Intent(getApplicationContext(), SurveyActivity.class));
                break;

            case NotificationHandler.ID_SCHWARZES_BRETT:
                startActivity(new Intent(getApplicationContext(), SchwarzesBrettActivity.class));
                break;
        }
    }
}
 
開發者ID:LCA311,項目名稱:leoapp-sources,代碼行數:37,代碼來源:MainActivity.java

示例9: examineBundle

import android.os.Bundle; //導入方法依賴的package包/類
/**
 * For debugging the intent extras
 *
 * @param bundle containing potential extras
 */
private void examineBundle(@Nullable final Bundle bundle) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "examineBundle");
    }

    if (bundle != null) {
        final Set<String> keys = bundle.keySet();
        for (final String key : keys) {
            if (DEBUG) {
                MyLog.v(CLS_NAME, "examineBundle: " + key + " ~ " + bundle.get(key));
            }
        }
    }
}
 
開發者ID:brandall76,項目名稱:Saiy-PS,代碼行數:20,代碼來源:AssistantIntentService.java

示例10: readSerializableMap

import android.os.Bundle; //導入方法依賴的package包/類
public static <T extends Serializable> Map<String, T> readSerializableMap(Parcel parcel) {
    Map<String, T> map = new ArrayMap<>();
    Bundle bundle = parcel.readBundle(Parcelables.class.getClassLoader());
    for (String key : bundle.keySet()) {
        @SuppressWarnings("unchecked")
        T serializable = (T) bundle.getSerializable(key);
        map.put(key, serializable);
    }
    return map;
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:11,代碼來源:Parcelables.java

示例11: restoreState

import android.os.Bundle; //導入方法依賴的package包/類
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        Parcelable[] fss = bundle.getParcelableArray("states");
        this.mSavedState.clear();
        this.mFragments.clear();
        if (fss != null) {
            for (Parcelable parcelable : fss) {
                this.mSavedState.add((SavedState) parcelable);
            }
        }
        for (String key : bundle.keySet()) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = this.mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (this.mFragments.size() <= index) {
                        this.mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    this.mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:30,代碼來源:FragmentStatePagerAdapter.java

示例12: insertAccountIntoDatabase

import android.os.Bundle; //導入方法依賴的package包/類
private boolean insertAccountIntoDatabase(int userId, Account account, String password, Bundle extras) {
	if (account == null) {
		return false;
	}
	synchronized (accountsByUserId) {
           VAccount vAccount = new VAccount(userId, account);
           vAccount.password = password;
           // convert the [Bundle] to [Map<String, String>]
           if (extras != null) {
               for (String key : extras.keySet()) {
                   Object value = extras.get(key);
                   if (value instanceof String) {
                       vAccount.userDatas.put(key, (String) value);
                   }
               }
           }
           List<VAccount> accounts = accountsByUserId.get(userId);
           if (accounts == null) {
               accounts = new ArrayList<>();
               accountsByUserId.put(userId, accounts);
           }
           accounts.add(vAccount);
           serializeAllAccounts();
           sendAccountsChangedBroadcast(vAccount.userId);
           return true;
       }
}
 
開發者ID:codehz,項目名稱:container,代碼行數:28,代碼來源:VAccountManagerService.java

示例13: getReferrerUrlIncludingExtraHeaders

import android.os.Bundle; //導入方法依賴的package包/類
/**
 * Gets the referrer, looking in the Intent extra and in the extra headers extra.
 *
 * The referrer extra takes priority over the "extra headers" one.
 *
 * @param intent The Intent containing the extras.
 * @param context The application context.
 * @return The referrer, or null.
 */
public static String getReferrerUrlIncludingExtraHeaders(Intent intent, Context context) {
    String referrerUrl = getReferrerUrl(intent, context);
    if (referrerUrl != null) return referrerUrl;

    Bundle bundleExtraHeaders = IntentUtils.safeGetBundleExtra(intent, Browser.EXTRA_HEADERS);
    if (bundleExtraHeaders == null) return null;
    for (String key : bundleExtraHeaders.keySet()) {
        String value = bundleExtraHeaders.getString(key);
        if ("referer".equals(key.toLowerCase(Locale.US)) && isValidReferrerHeader(value)) {
            return value;
        }
    }
    return null;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:24,代碼來源:IntentHandler.java

示例14: logBundle

import android.os.Bundle; //導入方法依賴的package包/類
public static void logBundle(Bundle data) {
    if (data != null) {
        Set<String> keys = data.keySet();
        StringBuilder stringBuilder = new StringBuilder();
        for (String key : keys) {
            Object value = data.get(key);
            stringBuilder.append(key)
                    .append("=")
                    .append(value)
                    .append(value == null ? "" : " (" + value.getClass().getSimpleName() + ")")
                    .append("\r\n");
        }
        Log.d(TAG, stringBuilder.toString());
    }
}
 
開發者ID:miankai,項目名稱:MKAPP,代碼行數:16,代碼來源:Util.java

示例15: containsAll

import android.os.Bundle; //導入方法依賴的package包/類
/**
 * Returns true if {@param original} contains all entries defined in {@param updates} and
 * have the same value.
 * The comparison uses {@link Object#equals(Object)} to compare the values.
 */
public static boolean containsAll(Bundle original, Bundle updates) {
    for (String key : updates.keySet()) {
        Object value1 = updates.get(key);
        Object value2 = original.get(key);
        if (value1 == null) {
            if (value2 != null) {
                return false;
            }
        } else if (!value1.equals(value2)) {
            return false;
        }
    }
    return true;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:20,代碼來源:Utilities.java


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