List of usage examples for android.os Bundle containsKey
public boolean containsKey(String key)
From source file:org.wheelmap.android.net.AbstractExecutor.java
public static IExecutor create(Context context, Bundle bundle, IAppProperties appProperties, ICredentials credentials, IHttpUserAgent httpUserAgent) { if (bundle == null || !bundle.containsKey(Extra.WHAT)) { return null; }/*from w w w.j a v a 2 s. c om*/ int what = bundle.getInt(Extra.WHAT); IExecutor executor; switch (what) { case What.RETRIEVE_NODE: executor = new NodeExecutor(context, bundle); break; case What.RETRIEVE_MARKER_ICONS: executor = new MarkerIconExecutor(context, bundle); break; case What.RETRIEVE_NODES: case What.SEARCH_NODES: case What.SEARCH_NODES_IN_BOX: executor = new NodesExecutor(context, bundle); break; case What.RETRIEVE_TOTAL_NODE_COUNT: executor = new TotalNodeCountExecutor(context, bundle); break; case What.RETRIEVE_LOCALES: executor = new LocalesExecutor(context, bundle); break; case What.RETRIEVE_CATEGORIES: executor = new CategoriesExecutor(context, bundle); break; case What.RETRIEVE_NODETYPES: executor = new NodeTypesExecutor(context, bundle); break; case What.UPDATE_SERVER: executor = new NodeUpdateOrNewExecutor(context); break; case What.RETRIEVE_APIKEY: executor = new ApiKeyExecutor(context, bundle); break; case What.RETRIEVE_PHOTO: executor = new PhotosExecutor(context, bundle); break; case What.UPDATE_PHOTO: executor = new PhotoExecutor(context, bundle); break; default: return null; // noop no instruction, no operation; } executor.setAppProperties(appProperties); executor.setCredentials(credentials); executor.setUserAgent(httpUserAgent.getAppUserAgent()); return executor; }
From source file:com.neusou.bioroid.restful.RestfulClient.java
public static Parcelable getParcelable(Bundle data, String name) { boolean invocation = data.containsKey(name); if (!invocation) { return null; }/* ww w .ja va 2 s.co m*/ return data.getParcelable(name); }
From source file:com.facebook.LegacyTokenHelper.java
public static AccessTokenSource getSource(Bundle bundle) { Validate.notNull(bundle, "bundle"); if (bundle.containsKey(TOKEN_SOURCE_KEY)) { return (AccessTokenSource) bundle.getSerializable(TOKEN_SOURCE_KEY); } else {/*from w ww . j a v a2 s . com*/ boolean isSSO = bundle.getBoolean(IS_SSO_KEY); return isSSO ? AccessTokenSource.FACEBOOK_APPLICATION_WEB : AccessTokenSource.WEB_VIEW; } }
From source file:io.teak.sdk.TeakNotification.java
static TeakNotification remoteNotificationFromIntent(final Context context, Intent intent) { final Bundle bundle = intent.getExtras(); if (!bundle.containsKey("teakNotifId")) { return null; }/*from w w w . ja v a2 s.com*/ final TeakNotification ret = new TeakNotification(bundle); new Thread(new Runnable() { @Override public void run() { // Add platformId to bundle bundle.putInt("platformId", ret.platformId); // Create native notification Notification nativeNotification = NotificationBuilder.createNativeNotification(context, bundle, ret); if (nativeNotification != null) { displayNotification(context, ret, nativeNotification); } } }).start(); return ret; }
From source file:Main.java
/** * Compares two {@link android.os.Bundle Bundles} to check for equality. * * @param a the first {@link android.os.Bundle Bundle} * @param b the second {@link android.os.Bundle Bundle} * @return {@code true} if the two {@link android.os.Bundle Bundles} have identical contents, or are both null */// w w w . j av a 2 s . co m public static boolean areEqual(@Nullable Bundle a, @Nullable Bundle b) { // equal if both null if (a == null && b == null) return true; // unequal if one is null if (a == null || b == null) return false; // check size if (a.size() != b.size()) return false; // get key sets Set<String> bundleAKeys = a.keySet(); Object valueA; Object valueB; // loop keys for (String key : bundleAKeys) { // check key exists in second bundle if (!b.containsKey(key)) return false; // get values valueA = a.get(key); valueB = b.get(key); // check null valued entries if (valueA == null && valueB == null) continue; if (valueA == null || valueB == null) return false; // compare iteratively if they are both bundles if (valueA instanceof Bundle && valueB instanceof Bundle) { if (!areEqual((Bundle) valueA, (Bundle) valueB)) return false; continue; } // check for different values if (!valueA.equals(valueB)) return false; } // passed! return true; }
From source file:com.onesignal.NotificationBundleProcessor.java
private static void saveNotification(Context context, Bundle bundle, boolean opened, int notificationId) { try {// w w w .j a va 2 s .com JSONObject customJSON = new JSONObject(bundle.getString("custom")); OneSignalDbHelper dbHelper = new OneSignalDbHelper(context); SQLiteDatabase writableDb = dbHelper.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(NotificationTable.COLUMN_NAME_NOTIFICATION_ID, customJSON.getString("i")); if (bundle.containsKey("grp")) values.put(NotificationTable.COLUMN_NAME_GROUP_ID, bundle.getString("grp")); values.put(NotificationTable.COLUMN_NAME_OPENED, opened ? 1 : 0); if (!opened) values.put(NotificationTable.COLUMN_NAME_ANDROID_NOTIFICATION_ID, notificationId); if (bundle.containsKey("title")) values.put(NotificationTable.COLUMN_NAME_TITLE, bundle.getString("title")); values.put(NotificationTable.COLUMN_NAME_MESSAGE, bundle.getString("alert")); values.put(NotificationTable.COLUMN_NAME_FULL_DATA, bundleAsJSONObject(bundle).toString()); writableDb.insert(NotificationTable.TABLE_NAME, null, values); // Clean up old records that have been dismissed or opened already after 1 week. writableDb.delete(NotificationTable.TABLE_NAME, NotificationTable.COLUMN_NAME_CREATED_TIME + " < " + ((System.currentTimeMillis() / 1000) - 604800) + " AND " + "(" + NotificationTable.COLUMN_NAME_DISMISSED + " = 1 OR " + NotificationTable.COLUMN_NAME_OPENED + " = 1" + ")", null); writableDb.close(); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.onesignal.NotificationBundleProcessor.java
public static void Process(Context context, Bundle bundle) { if (OneSignal.isValidAndNotDuplicated(context, bundle)) { boolean showAsAlert = OneSignal.getInAppAlertNotificationEnabled(context); boolean isActive = OneSignal.initDone && OneSignal.isForeground(); boolean display = OneSignal.getNotificationsWhenActiveEnabled(context) || showAsAlert || !isActive; prepareBundle(bundle);//from w ww. j a v a 2s. c o m BackgroundBroadcaster.Invoke(context, bundle, isActive); if (!bundle.containsKey("alert") || bundle.getString("alert") == null || bundle.getString("alert").equals("")) return; int notificationId = -1; if (display)// Build notification from the Bundle notificationId = GenerateNotification.fromBundle(context, bundle, showAsAlert && isActive); else { final Bundle finalBundle = bundle; // Current thread is meant to be short lived. Make a new thread to do our OneSignal work on. new Thread(new Runnable() { public void run() { OneSignal.handleNotificationOpened( NotificationBundleProcessor.bundleAsJsonArray(finalBundle)); } }).start(); } saveNotification(context, bundle, !display, notificationId); } }
From source file:com.example.jumpnote.android.jsonrpc.AuthenticatedJsonRpcJavaClient.java
public static void ensureHasTokenWithUI(Activity activity, Account account, final EnsureHasTokenWithUICallback callback) { AccountManager am = AccountManager.get(activity); am.getAuthToken(account, APPENGINE_SERVICE_NAME, null, activity, new AccountManagerCallback<Bundle>() { public void run(AccountManagerFuture<Bundle> authBundleFuture) { Bundle authBundle = null; try { authBundle = authBundleFuture.getResult(); } catch (OperationCanceledException e) { callback.onAuthDenied(); return; } catch (AuthenticatorException e) { callback.onError(e);// w ww.j a v a 2 s . c o m return; } catch (IOException e) { callback.onError(e); return; } if (authBundle.containsKey(AccountManager.KEY_AUTHTOKEN)) { callback.onHasToken((String) authBundle.get(AccountManager.KEY_AUTHTOKEN)); } else { callback.onError( new IllegalStateException("No auth token available, but operation not canceled.")); } } }, null); }
From source file:com.facebook.share.internal.ShareInternalUtility.java
/** * Determines whether the native dialog completed normally (without error or exception). * * @param result the bundle passed back to onActivityResult * @return true if the native dialog completed normally *//*from w w w .ja v a 2 s . c om*/ public static boolean getNativeDialogDidComplete(Bundle result) { if (result.containsKey(NativeProtocol.RESULT_ARGS_DIALOG_COMPLETE_KEY)) { return result.getBoolean(NativeProtocol.RESULT_ARGS_DIALOG_COMPLETE_KEY); } return result.getBoolean(NativeProtocol.EXTRA_DIALOG_COMPLETE_KEY, false); }
From source file:com.facebook.share.internal.ShareInternalUtility.java
/** * Returns the gesture with which the user completed the native dialog. This is only returned * if the user has previously authorized the calling app with basic permissions. * * @param result the bundle passed back to onActivityResult * @return "post" or "cancel" as the completion gesture *///w w w .j av a 2 s .c om public static String getNativeDialogCompletionGesture(Bundle result) { if (result.containsKey(NativeProtocol.RESULT_ARGS_DIALOG_COMPLETION_GESTURE_KEY)) { return result.getString(NativeProtocol.RESULT_ARGS_DIALOG_COMPLETION_GESTURE_KEY); } return result.getString(NativeProtocol.EXTRA_DIALOG_COMPLETION_GESTURE_KEY); }