当前位置: 首页>>代码示例>>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;未经允许,请勿转载。