List of usage examples for android.os Bundle putStringArray
public void putStringArray(@Nullable String key, @Nullable String[] value)
From source file:com.googlecode.android_scripting.facade.AndroidFacade.java
private static void putNestedJSONObject(JSONObject jsonObject, Bundle bundle) throws JSONException { JSONArray names = jsonObject.names(); for (int i = 0; i < names.length(); i++) { String name = names.getString(i); Object data = jsonObject.get(name); if (data == null) { continue; }/*from ww w . j a v a2 s . c om*/ if (data instanceof Integer) { bundle.putInt(name, ((Integer) data).intValue()); } if (data instanceof Float) { bundle.putFloat(name, ((Float) data).floatValue()); } if (data instanceof Double) { bundle.putDouble(name, ((Double) data).doubleValue()); } if (data instanceof Long) { bundle.putLong(name, ((Long) data).longValue()); } if (data instanceof String) { bundle.putString(name, (String) data); } if (data instanceof Boolean) { bundle.putBoolean(name, ((Boolean) data).booleanValue()); } // Nested JSONObject if (data instanceof JSONObject) { Bundle nestedBundle = new Bundle(); bundle.putBundle(name, nestedBundle); putNestedJSONObject((JSONObject) data, nestedBundle); } // Nested JSONArray. Doesn't support mixed types in single array if (data instanceof JSONArray) { // Empty array. No way to tell what type of data to pass on, so skipping if (((JSONArray) data).length() == 0) { Log.e("Empty array not supported in nested JSONObject, skipping"); continue; } // Integer if (((JSONArray) data).get(0) instanceof Integer) { int[] integerArrayData = new int[((JSONArray) data).length()]; for (int j = 0; j < ((JSONArray) data).length(); ++j) { integerArrayData[j] = ((JSONArray) data).getInt(j); } bundle.putIntArray(name, integerArrayData); } // Double if (((JSONArray) data).get(0) instanceof Double) { double[] doubleArrayData = new double[((JSONArray) data).length()]; for (int j = 0; j < ((JSONArray) data).length(); ++j) { doubleArrayData[j] = ((JSONArray) data).getDouble(j); } bundle.putDoubleArray(name, doubleArrayData); } // Long if (((JSONArray) data).get(0) instanceof Long) { long[] longArrayData = new long[((JSONArray) data).length()]; for (int j = 0; j < ((JSONArray) data).length(); ++j) { longArrayData[j] = ((JSONArray) data).getLong(j); } bundle.putLongArray(name, longArrayData); } // String if (((JSONArray) data).get(0) instanceof String) { String[] stringArrayData = new String[((JSONArray) data).length()]; for (int j = 0; j < ((JSONArray) data).length(); ++j) { stringArrayData[j] = ((JSONArray) data).getString(j); } bundle.putStringArray(name, stringArrayData); } // Boolean if (((JSONArray) data).get(0) instanceof Boolean) { boolean[] booleanArrayData = new boolean[((JSONArray) data).length()]; for (int j = 0; j < ((JSONArray) data).length(); ++j) { booleanArrayData[j] = ((JSONArray) data).getBoolean(j); } bundle.putBooleanArray(name, booleanArrayData); } } } }
From source file:org.opendatakit.survey.activities.MainMenuActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { // TODO Auto-generated method stub super.onSaveInstanceState(outState); if (dispatchStringWaitingForData != null) { outState.putString(DISPATCH_STRING_WAITING_FOR_DATA, dispatchStringWaitingForData); }/*from w ww . j av a 2s . c om*/ if (actionWaitingForData != null) { outState.putString(ACTION_WAITING_FOR_DATA, actionWaitingForData); } outState.putString(CURRENT_FRAGMENT, currentFragment.name()); if (getCurrentForm() != null) { outState.putString(FORM_URI, getCurrentForm().formUri.toString()); } if (getInstanceId() != null) { outState.putString(INSTANCE_ID, getInstanceId()); } if (getUploadTableId() != null) { outState.putString(UPLOAD_TABLE_ID, getUploadTableId()); } if (getScreenPath() != null) { outState.putString(SCREEN_PATH, getScreenPath()); } if (getControllerState() != null) { outState.putString(CONTROLLER_STATE, getControllerState()); } if (getAuxillaryHash() != null) { outState.putString(AUXILLARY_HASH, getAuxillaryHash()); } if (getAppName() != null) { outState.putString(IntentConsts.INTENT_KEY_APP_NAME, getAppName()); } outState.putBundle(SESSION_VARIABLES, sessionVariables); outState.putParcelableArrayList(SECTION_STATE_SCREEN_HISTORY, sectionStateScreenHistory); if (!queuedActions.isEmpty()) { String[] actionOutcomesArray = new String[queuedActions.size()]; queuedActions.toArray(actionOutcomesArray); outState.putStringArray(QUEUED_ACTIONS, actionOutcomesArray); } if (!queueResponseJSON.isEmpty()) { String[] qra = queueResponseJSON.toArray(new String[queueResponseJSON.size()]); outState.putStringArray(RESPONSE_JSON, qra); } if (mConflictTables != null && !mConflictTables.isEmpty()) { outState.putBundle(CONFLICT_TABLES, mConflictTables); } }
From source file:org.kontalk.service.msgcenter.MessageCenterService.java
private void sendMessages(Cursor c, boolean retrying) { // this set will cache thread IDs within this cursor with // pending group commands (i.e. just processed group commands) // This will be looked up when sending consecutive message in the group // and stop them Set<Long> pendingGroupCommandThreads = new HashSet<>(); while (c.moveToNext()) { long id = c.getLong(0); long threadId = c.getLong(1); String msgId = c.getString(2); String peer = c.getString(3); byte[] textContent = c.getBlob(4); String bodyMime = c.getString(5); int securityFlags = c.getInt(6); String attMime = c.getString(7); String attFileUri = c.getString(8); String attFetchUrl = c.getString(9); String attPreviewPath = c.getString(10); long attLength = c.getLong(11); int compress = c.getInt(12); // TODO int attSecurityFlags = c.getInt(13); String groupJid = c.getString(13); // 14 String groupSubject = c.getString(14); // 15 if (pendingGroupCommandThreads.contains(threadId)) { Log.v(TAG, "group message for pending group command - delaying"); continue; }//from www .j a va 2s. c o m final boolean isGroupCommand = GroupCommandComponent.supportsMimeType(bodyMime); if (isGroupCommand) { if (groupJid == null) { // orphan group command waiting to be sent groupJid = peer; } else { // cache the thread -- it will block future messages until // this command is received by the server pendingGroupCommandThreads.add(threadId); } } String[] groupMembers = null; if (groupJid != null) { /* * Huge potential issue here. Selecting all members, regardless of pending flags, * might e.g. deliver messages to removed users if there is a content message right * after a remove command. * However, selecting members with zero flags will make a remove command to be sent * only to existing members and not to the ones being removed. */ groupMembers = MessagesProviderUtils.getGroupMembers(this, groupJid, -1); if (groupMembers.length == 0) { // no group member left - skip message // this might be a pending message that was queued before we realized there were no members left // since the group might get populated again, we just skip the message but keep it Log.d(TAG, "no members in group - skipping message"); continue; } } // media message encountered and no upload service available - delay message if (attFileUri != null && attFetchUrl == null && getUploadService() == null && !retrying) { Log.w(TAG, "no upload info received yet, delaying media message"); continue; } Bundle b = new Bundle(); // mark as retrying b.putBoolean("org.kontalk.message.retrying", true); b.putLong("org.kontalk.message.msgId", id); b.putString("org.kontalk.message.packetId", msgId); if (groupJid != null) { b.putString("org.kontalk.message.group.jid", groupJid); b.putString("org.kontalk.message.group.subject", groupSubject); // will be replaced by the group command (if any) b.putStringArray("org.kontalk.message.to", groupMembers); } else { b.putString("org.kontalk.message.to", peer); } // TODO shouldn't we pass security flags directly here?? b.putBoolean("org.kontalk.message.encrypt", securityFlags != Coder.SECURITY_CLEARTEXT); if (isGroupCommand) { int cmd = 0; byte[] _command = c.getBlob(4); String command = new String(_command); String[] createMembers; String[] addMembers; String[] removeMembers = null; String subject; if ((createMembers = GroupCommandComponent.getCreateCommandMembers(command)) != null) { cmd = GROUP_COMMAND_CREATE; b.putStringArray("org.kontalk.message.to", createMembers); } else if (command.equals(GroupCommandComponent.COMMAND_PART)) { cmd = GROUP_COMMAND_PART; } else if ((addMembers = GroupCommandComponent.getAddCommandMembers(command)) != null || (removeMembers = GroupCommandComponent.getRemoveCommandMembers(command)) != null) { cmd = GROUP_COMMAND_MEMBERS; b.putStringArray("org.kontalk.message.group.add", addMembers); b.putStringArray("org.kontalk.message.group.remove", removeMembers); } else if ((subject = GroupCommandComponent.getSubjectCommand(command)) != null) { cmd = GROUP_COMMAND_SUBJECT; b.putString("org.kontalk.message.group.subject", subject); } b.putInt("org.kontalk.message.group.command", cmd); } else if (textContent != null) { b.putString("org.kontalk.message.body", MessageUtils.toString(textContent)); } // message has already been uploaded - just send media if (attFetchUrl != null) { b.putString("org.kontalk.message.mime", attMime); b.putString("org.kontalk.message.fetch.url", attFetchUrl); b.putString("org.kontalk.message.preview.uri", attFileUri); b.putString("org.kontalk.message.preview.path", attPreviewPath); } // check if the message contains some large file to be sent else if (attFileUri != null) { b.putString("org.kontalk.message.mime", attMime); b.putString("org.kontalk.message.media.uri", attFileUri); b.putString("org.kontalk.message.preview.path", attPreviewPath); b.putLong("org.kontalk.message.length", attLength); b.putInt("org.kontalk.message.compress", compress); } Log.v(TAG, "resending pending message " + id); sendMessage(b); } }
From source file:org.zywx.wbpalmstar.engine.universalex.EUExWindow.java
public void close(String[] parm) { Message msg = mHandler.obtainMessage(); msg.what = MSG_FUNCTION_CLOSE;/*from w w w . j av a 2s .c om*/ msg.obj = this; Bundle bd = new Bundle(); bd.putStringArray(TAG_BUNDLE_PARAM, parm); msg.setData(bd); mHandler.sendMessage(msg); }
From source file:org.zywx.wbpalmstar.engine.universalex.EUExWindow.java
public void windowBack(String[] parm) { Message msg = new Message(); msg.obj = this; msg.what = MSG_FUNCTION_WINDOWBACK;/*from w w w . ja v a 2 s . com*/ Bundle bd = new Bundle(); bd.putStringArray(TAG_BUNDLE_PARAM, parm); msg.setData(bd); mHandler.sendMessage(msg); }
From source file:org.zywx.wbpalmstar.engine.universalex.EUExWindow.java
public void windowForward(String[] parm) { Message msg = new Message(); msg.obj = this; msg.what = MSG_FUNCTION_WINDOWFORWARD; Bundle bd = new Bundle(); bd.putStringArray(TAG_BUNDLE_PARAM, parm); msg.setData(bd);//from www . j a v a 2 s .c om mHandler.sendMessage(msg); }
From source file:org.zywx.wbpalmstar.engine.universalex.EUExWindow.java
public void showSoftKeyboard(String[] params) { Message msg = new Message(); msg.obj = this; msg.what = MSG_SHOW_SOFT_KEYBOARD;/*from www .j a v a 2s . c o m*/ Bundle bd = new Bundle(); bd.putStringArray(TAG_BUNDLE_PARAM, params); msg.setData(bd); mHandler.sendMessage(msg); }
From source file:org.zywx.wbpalmstar.engine.universalex.EUExWindow.java
public void destroyProgressDialog(String[] params) { Message msg = new Message(); msg.obj = this; msg.what = MSG_DESTROY_PROGRESS_DIALOG; Bundle bd = new Bundle(); bd.putStringArray(TAG_BUNDLE_PARAM, params); msg.setData(bd);/*from w ww . ja v a 2s. co m*/ mHandler.sendMessage(msg); }
From source file:org.zywx.wbpalmstar.engine.universalex.EUExWindow.java
public void createPluginViewContainer(String[] parm) { Message msg = mHandler.obtainMessage(); msg.what = MSG_PLUGINVIEW_CONTAINER_CREATE; msg.obj = this; Bundle bd = new Bundle(); bd.putStringArray(TAG_BUNDLE_PARAM, parm); msg.setData(bd);// ww w .j av a2 s. c o m mHandler.sendMessage(msg); }
From source file:org.zywx.wbpalmstar.engine.universalex.EUExWindow.java
public void showPluginViewContainer(String[] parm) { Message msg = mHandler.obtainMessage(); msg.what = MSG_PLUGINVIEW_CONTAINER_SHOW; msg.obj = this; Bundle bd = new Bundle(); bd.putStringArray(TAG_BUNDLE_PARAM, parm); msg.setData(bd);/*from w w w. j a v a 2 s .com*/ mHandler.sendMessage(msg); }