Java Code Examples for android.os.Bundle.putStringArray()

The following are Jave code examples for showing how to use putStringArray() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: letv   File: FragmentActivity.java   View Source Code Vote up 7 votes
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Parcelable p = this.mFragments.saveAllState();
    if (p != null) {
        outState.putParcelable(FRAGMENTS_TAG, p);
    }
    if (this.mPendingFragmentActivityResults.size() > 0) {
        outState.putInt(NEXT_CANDIDATE_REQUEST_INDEX_TAG, this.mNextCandidateRequestIndex);
        int[] requestCodes = new int[this.mPendingFragmentActivityResults.size()];
        String[] fragmentWhos = new String[this.mPendingFragmentActivityResults.size()];
        for (int i = 0; i < this.mPendingFragmentActivityResults.size(); i++) {
            requestCodes[i] = this.mPendingFragmentActivityResults.keyAt(i);
            fragmentWhos[i] = (String) this.mPendingFragmentActivityResults.valueAt(i);
        }
        outState.putIntArray(ALLOCATED_REQUEST_INDICIES_TAG, requestCodes);
        outState.putStringArray(REQUEST_FRAGMENT_WHO_TAG, fragmentWhos);
    }
}
 
Example 2
Project: boohee_v5.6   File: ChartletFragment.java   View Source Code Vote up 6 votes
public static ChartletFragment newInstance(int[] thumbnailIds, int[] drawableIds, String[]
        strings, String imageUriStr) {
    if (thumbnailIds == null || thumbnailIds.length == 0 || drawableIds == null ||
            drawableIds.length == 0 || TextUtils.isEmpty(imageUriStr)) {
        return null;
    }
    ChartletFragment fragment = new ChartletFragment();
    Bundle args = new Bundle();
    args.putIntArray(KEY_DRAWABLE_IDS, drawableIds);
    args.putIntArray(KEY_THUMBNAIL_DRAWABLE_IDS, thumbnailIds);
    if (strings != null && strings.length > 0) {
        args.putStringArray(KEY_STRINGS, strings);
    }
    args.putString(KEY_URI_STR, imageUriStr);
    fragment.setArguments(args);
    return fragment;
}
 
Example 3
Project: boohee_v5.6   File: FragmentActivity.java   View Source Code Vote up 6 votes
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Parcelable p = this.mFragments.saveAllState();
    if (p != null) {
        outState.putParcelable(FRAGMENTS_TAG, p);
    }
    if (this.mPendingFragmentActivityResults.size() > 0) {
        outState.putInt(NEXT_CANDIDATE_REQUEST_INDEX_TAG, this.mNextCandidateRequestIndex);
        int[] requestCodes = new int[this.mPendingFragmentActivityResults.size()];
        String[] fragmentWhos = new String[this.mPendingFragmentActivityResults.size()];
        for (int i = 0; i < this.mPendingFragmentActivityResults.size(); i++) {
            requestCodes[i] = this.mPendingFragmentActivityResults.keyAt(i);
            fragmentWhos[i] = (String) this.mPendingFragmentActivityResults.valueAt(i);
        }
        outState.putIntArray(ALLOCATED_REQUEST_INDICIES_TAG, requestCodes);
        outState.putStringArray(REQUEST_FRAGMENT_WHO_TAG, fragmentWhos);
    }
}
 
Example 4
Project: q-mail   File: RemoteControlReceiver.java   View Source Code Vote up 5 votes
@Override
public Integer receive(Context context, Intent intent, Integer tmpWakeLockId) {
    Timber.i("RemoteControlReceiver.onReceive %s", intent);

    if (K9RemoteControl.K9_SET.equals(intent.getAction())) {
        RemoteControlService.set(context, intent, tmpWakeLockId);
        tmpWakeLockId = null;
    } else if (K9RemoteControl.K9_REQUEST_ACCOUNTS.equals(intent.getAction())) {
        try {
            Preferences preferences = Preferences.getPreferences(context);
            List<Account> accounts = preferences.getAccounts();
            String[] uuids = new String[accounts.size()];
            String[] descriptions = new String[accounts.size()];
            for (int i = 0; i < accounts.size(); i++) {
                //warning: account may not be isAvailable()
                Account account = accounts.get(i);

                uuids[i] = account.getUuid();
                descriptions[i] = account.getDescription();
            }
            Bundle bundle = getResultExtras(true);
            bundle.putStringArray(K9_ACCOUNT_UUIDS, uuids);
            bundle.putStringArray(K9_ACCOUNT_DESCRIPTIONS, descriptions);
        } catch (Exception e) {
            Timber.e(e, "Could not handle K9_RESPONSE_INTENT");
        }

    }

    return tmpWakeLockId;
}
 
Example 5
Project: CXJPadProject   File: RationaleDialogConfig.java   View Source Code Vote up 5 votes
Bundle toBundle() {
    Bundle bundle = new Bundle();
    bundle.putInt(KEY_POSITIVE_BUTTON, positiveButton);
    bundle.putInt(KEY_NEGATIVE_BUTTON, negativeButton);
    bundle.putString(KEY_RATIONALE_MESSAGE, rationaleMsg);
    bundle.putInt(KEY_REQUEST_CODE, requestCode);
    bundle.putStringArray(KEY_PERMISSIONS, permissions);

    return bundle;
}
 
Example 6
Project: javaide   File: RecordLogDialogActivity.java   View Source Code Vote up 5 votes
public static ShowRecordLogDialog newInstance(String[] suggestions) {
    ShowRecordLogDialog dialog = new ShowRecordLogDialog();
    Bundle args = new Bundle();
    args.putStringArray(QUERY_SUGGESTIONS, suggestions);
    dialog.setArguments(args);
    return dialog;
}
 
Example 7
Project: Tess-TwoDemo   File: CameraActivity.java   View Source Code Vote up 5 votes
public static ConfirmationDialogFragment newInstance(@StringRes int message,
                                                     String[] permissions, int requestCode, @StringRes int notGrantedMessage) {
    ConfirmationDialogFragment fragment = new ConfirmationDialogFragment();
    Bundle args = new Bundle();
    args.putInt(ARG_MESSAGE, message);
    args.putStringArray(ARG_PERMISSIONS, permissions);
    args.putInt(ARG_REQUEST_CODE, requestCode);
    args.putInt(ARG_NOT_GRANTED_MESSAGE, notGrantedMessage);
    fragment.setArguments(args);
    return fragment;
}
 
Example 8
Project: AndroidBackendlessChat   File: AppLinkData.java   View Source Code Vote up 5 votes
private static Bundle toBundle(JSONObject node) throws JSONException {
    Bundle bundle = new Bundle();
    @SuppressWarnings("unchecked")
    Iterator<String> fields = node.keys();
    while (fields.hasNext()) {
        String key = fields.next();
        Object value;
        value = node.get(key);

        if (value instanceof JSONObject) {
            bundle.putBundle(key, toBundle((JSONObject) value));
        } else if (value instanceof JSONArray) {
            JSONArray valueArr = (JSONArray) value;
            if (valueArr.length() == 0) {
                bundle.putStringArray(key, new String[0]);
            } else {
                Object firstNode = valueArr.get(0);
                if (firstNode instanceof JSONObject) {
                    Bundle[] bundles = new Bundle[valueArr.length()];
                    for (int i = 0; i < valueArr.length(); i++) {
                        bundles[i] = toBundle(valueArr.getJSONObject(i));
                    }
                    bundle.putParcelableArray(key, bundles);
                } else if (firstNode instanceof JSONArray) {
                    // we don't support nested arrays
                    throw new FacebookException("Nested arrays are not supported.");
                } else { // just use the string value
                    String[] arrValues = new String[valueArr.length()];
                    for (int i = 0; i < valueArr.length(); i++) {
                        arrValues[i] = valueArr.get(i).toString();
                    }
                    bundle.putStringArray(key, arrValues);
                }
            }
        } else {
            bundle.putString(key, value.toString());
        }
    }
    return bundle;
}
 
Example 9
Project: ucar-weex-core   File: ArgumentsUtil.java   View Source Code Vote up 5 votes
public static void fromArrayToBundle(Bundle bundle, String key, Object array) {
    if (bundle != null && !TextUtils.isEmpty(key) && array != null) {
        if (array instanceof String[]) {
            bundle.putStringArray(key, (String[]) ((String[]) array));
        } else if (array instanceof byte[]) {
            bundle.putByteArray(key, (byte[]) ((byte[]) array));
        } else if (array instanceof short[]) {
            bundle.putShortArray(key, (short[]) ((short[]) array));
        } else if (array instanceof int[]) {
            bundle.putIntArray(key, (int[]) ((int[]) array));
        } else if (array instanceof long[]) {
            bundle.putLongArray(key, (long[]) ((long[]) array));
        } else if (array instanceof float[]) {
            bundle.putFloatArray(key, (float[]) ((float[]) array));
        } else if (array instanceof double[]) {
            bundle.putDoubleArray(key, (double[]) ((double[]) array));
        } else if (array instanceof boolean[]) {
            bundle.putBooleanArray(key, (boolean[]) ((boolean[]) array));
        } else if (array instanceof char[]) {
            bundle.putCharArray(key, (char[]) ((char[]) array));
        } else {
            if (!(array instanceof JSONArray)) {
                throw new IllegalArgumentException("Unknown array type " + array.getClass());
            }

            ArrayList arraylist = new ArrayList();
            JSONArray jsonArray = (JSONArray) array;
            Iterator it = jsonArray.iterator();

            while (it.hasNext()) {
                JSONObject object = (JSONObject) it.next();
                arraylist.add(fromJsonToBundle(object));
            }

            bundle.putParcelableArrayList(key, arraylist);
        }

    }
}
 
Example 10
Project: boohee_v5.6   File: QzoneShare.java   View Source Code Vote up 5 votes
private StringBuffer a(StringBuffer stringBuffer, Bundle bundle) {
    f.c(f.d, "fillShareToQQParams() --start");
    ArrayList stringArrayList = bundle.getStringArrayList("imageUrl");
    Object string = bundle.getString("appName");
    int i = bundle.getInt("req_type", 1);
    String string2 = bundle.getString("title");
    String string3 = bundle.getString("summary");
    bundle.putString("appId", this.mToken.getAppId());
    bundle.putString("sdkp", "a");
    bundle.putString(SocializeProtocolConstants.PROTOCOL_KEY_VERSION, Constants.SDK_VERSION);
    bundle.putString("status_os", VERSION.RELEASE);
    bundle.putString("status_machine", Build.MODEL);
    String str = "...";
    if (!Util.isEmpty(string2) && string2.length() > 40) {
        bundle.putString("title", string2.substring(0, 40) + "...");
    }
    if (!Util.isEmpty(string3) && string3.length() > 80) {
        bundle.putString("summary", string3.substring(0, 80) + "...");
    }
    if (!TextUtils.isEmpty(string)) {
        bundle.putString("site", string);
    }
    if (stringArrayList != null) {
        int size = stringArrayList.size();
        String[] strArr = new String[size];
        for (int i2 = 0; i2 < size; i2++) {
            strArr[i2] = (String) stringArrayList.get(i2);
        }
        bundle.putStringArray("imageUrl", strArr);
    }
    bundle.putString("type", String.valueOf(i));
    stringBuffer.append(com.alipay.sdk.sys.a.b + Util.encodeUrl(bundle).replaceAll("\\+", "%20"));
    f.c(f.d, "fillShareToQQParams() --end");
    return stringBuffer;
}
 
Example 11
Project: NeiHanDuanZiTV   File: ArmsUtils.java   View Source Code Vote up 5 votes
/**
 * 展示一个底部显示的对话框
 *
 * @param title           标题 可为空
 * @param msg             内容 可为空
 * @param accentStrs      高亮显示的文本item 可为空
 * @param strs            普通item  可为空
 * @param onClickListener 点击事件
 */
public static void showAlertDialog(String title, String msg, String[] accentStrs, String[] strs, OnItemClickListener onClickListener) {
    Message message = new Message();
    message.what = SHOW_ALERTVIEW_BOTTOM;
    message.obj = onClickListener;
    Bundle bundle = new Bundle();
    bundle.putString("title", title);
    bundle.putString("msg", msg);
    bundle.putStringArray("accentStrs", accentStrs);
    bundle.putStringArray("strs", strs);
    message.setData(bundle);
    EventBus.getDefault().post(message, APPMANAGER_MESSAGE);
}
 
Example 12
Project: Saiy-PS   File: PermissionHelper.java   View Source Code Vote up 5 votes
/**
 * Check if the user has granted the contacts group permission
 *
 * @param ctx the application context
 * @return true if the permissions have been granted. False if they have been denied or are
 * required to be requested.
 */
public static boolean checkContactGroupPermissions(@NonNull final Context ctx) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "checkContactGroupPermissions");
    }

    switch (ContextCompat.checkSelfPermission(ctx, android.Manifest.permission.GET_ACCOUNTS)) {

        case PackageManager.PERMISSION_GRANTED:
            if (DEBUG) {
                MyLog.i(CLS_NAME, "checkContactGroupPermissions: PERMISSION_GRANTED");
            }
            return true;
        case PackageManager.PERMISSION_DENIED:
        default:
            if (DEBUG) {
                MyLog.w(CLS_NAME, "checkContactGroupPermissions: PERMISSION_DENIED");
            }

            final Intent intent = new Intent(ctx, ActivityPermissionDialog.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            final Bundle bundle = new Bundle();
            bundle.putStringArray(REQUESTED_PERMISSION, new String[]{android.Manifest.permission.GET_ACCOUNTS});
            bundle.putInt(REQUESTED_PERMISSION_ID, REQUEST_GROUP_CONTACTS);

            intent.putExtras(bundle);

            ctx.startActivity(intent);
            return false;
    }
}
 
Example 13
Project: chromium-for-android-56-debug-video   File: ConfirmImportantSitesDialogFragment.java   View Source Code Vote up 5 votes
/**
 * Constructs a new instance of the important sites dialog fragment.
 * @param importantDomains The list of important domains to display.
 * @param importantDomainReasons The reasons for choosing each important domain.
 * @param faviconURLs The list of favicon urls that correspond to each importantDomains.
 * @return An instance of ConfirmImportantSitesDialogFragment with the bundle arguments set.
 */
public static ConfirmImportantSitesDialogFragment newInstance(
        String[] importantDomains, int[] importantDomainReasons, String[] faviconURLs) {
    ConfirmImportantSitesDialogFragment dialogFragment =
            new ConfirmImportantSitesDialogFragment();
    Bundle bundle = new Bundle();
    bundle.putStringArray(IMPORTANT_DOMAINS_TAG, importantDomains);
    bundle.putIntArray(IMPORTANT_DOMAIN_REASONS_TAG, importantDomainReasons);
    bundle.putStringArray(FAVICON_URLS_TAG, faviconURLs);
    dialogFragment.setArguments(bundle);
    return dialogFragment;
}
 
Example 14
Project: revolution-irc   File: ChatPagerAdapter.java   View Source Code Vote up 5 votes
public void onSaveInstanceState(Bundle outBundle) {
    String[] keys = new String[channelIds.size()];
    long[] values = new long[channelIds.size()];
    Iterator<Map.Entry<String, Long>> it = channelIds.entrySet().iterator();
    int i = 0;
    while (it.hasNext()) {
        Map.Entry<String, Long> e = it.next();
        keys[i] = e.getKey();
        values[i] = e.getValue();
        ++i;
    }
    outBundle.putStringArray("channel_ids_keys", keys);
    outBundle.putLongArray("channel_ids_values", values);
}
 
Example 15
Project: GitHub   File: Injector.java   View Source Code Vote up 4 votes
public void putStringArray(Bundle state, String key, String[] x) {
    state.putStringArray(key + baseKey, x);
}
 
Example 16
Project: MRouter   File: MainActivity.java   View Source Code Vote up 4 votes
public Bundle assembleBundle() {
    User user = new User();
    user.setAge(90);
    user.setGender(1);
    user.setName("kitty");

    Address address = new Address();
    address.setCity("HangZhou");
    address.setProvince("ZheJiang");

    Bundle extras = new Bundle();
    extras.putString("extra", "from extras");


    ArrayList<String> stringList = new ArrayList<>();
    stringList.add("Java");
    stringList.add("C#");
    stringList.add("Kotlin");

    ArrayList<String> stringArrayList = new ArrayList<>();
    stringArrayList.add("American");
    stringArrayList.add("China");
    stringArrayList.add("England");

    ArrayList<Integer> intArrayList = new ArrayList<>();
    intArrayList.add(100);
    intArrayList.add(101);
    intArrayList.add(102);

    ArrayList<Integer> intList = new ArrayList<>();
    intList.add(10011);
    intList.add(10111);
    intList.add(10211);

    ArrayList<Address> addressList = new ArrayList<>();
    addressList.add(new Address("JiangXi", "ShangRao", null));
    addressList.add(new Address("ZheJiang", "NingBo", null));

    Address[] addressArray = new Address[]{
            new Address("Beijing", "Beijing", null),
            new Address("Shanghai", "Shanghai", null),
            new Address("Guangzhou", "Guangzhou", null)
    };
    Bundle bundle = new Bundle();
    bundle.putSerializable("user", user);
    bundle.putParcelable("address", address);
    bundle.putParcelableArrayList("addressList", addressList);
    bundle.putParcelableArray("addressArray", addressArray);
    bundle.putString("param", "chiclaim");
    bundle.putStringArray("stringArray", new String[]{"a", "b", "c"});
    bundle.putStringArrayList("stringArrayList", stringList);
    bundle.putStringArrayList("stringList", stringArrayList);
    bundle.putByte("byte", (byte) 2);
    bundle.putByteArray("byteArray", new byte[]{1, 2, 3, 4, 5});
    bundle.putInt("age", 33);
    bundle.putIntArray("intArray", new int[]{10, 11, 12, 13});
    bundle.putIntegerArrayList("intList", intList);
    bundle.putIntegerArrayList("intArrayList", intArrayList);
    bundle.putChar("chara", 'c');
    bundle.putCharArray("charArray", "chiclaim".toCharArray());
    bundle.putShort("short", (short) 1000000);
    bundle.putShortArray("shortArray", new short[]{(short) 10.9, (short) 11.9});
    bundle.putDouble("double", 1200000);
    bundle.putDoubleArray("doubleArray", new double[]{1232, 9999, 8789, 3.1415926});
    bundle.putLong("long", 999999999);
    bundle.putLongArray("longArray", new long[]{1000, 2000, 3000});
    bundle.putFloat("float", 333);
    bundle.putFloatArray("floatArray", new float[]{12.9f, 234.9f});
    bundle.putBoolean("boolean", true);
    bundle.putBooleanArray("booleanArray", new boolean[]{true, false, true});

    return bundle;
}
 
Example 17
Project: android-state   File: InjectionHelper.java   View Source Code Vote up 4 votes
public void putStringArray(Bundle state, String key, String[] x) {
    state.putStringArray(key + mBaseKey, x);
}
 
Example 18
Project: PhotoPicker-master   File: ImagePagerFragment.java   View Source Code Vote up 3 votes
public static ImagePagerFragment newInstance(List<String> paths, int currentItem) {

    ImagePagerFragment f = new ImagePagerFragment();

    Bundle args = new Bundle();
    args.putStringArray(ARG_PATH, paths.toArray(new String[paths.size()]));
    args.putInt(ARG_CURRENT_ITEM, currentItem);
    args.putBoolean(ARG_HAS_ANIM, false);

    f.setArguments(args);

    return f;
  }
 
Example 19
Project: Hitalk   File: ImagePagerFragment.java   View Source Code Vote up 3 votes
public static ImagePagerFragment newInstance(List<String> paths, int currentItem) {

    ImagePagerFragment f = new ImagePagerFragment();

    Bundle args = new Bundle();
    args.putStringArray(ARG_PATH, paths.toArray(new String[paths.size()]));
    args.putInt(ARG_CURRENT_ITEM, currentItem);
    args.putBoolean(ARG_HAS_ANIM, false);

    f.setArguments(args);

    return f;
  }
 
Example 20
Project: Lyra   File: StringArrayCoder.java   View Source Code Vote up 2 votes
/**
 * Write a field's value into the saved state {@link Bundle}.
 *
 * @param state      {@link Bundle} used to save the state
 * @param key        key retrieved from {@code fieldDeclaringClass#fieldName}
 * @param fieldValue value of field
 */
@Override
public void serialize(@NonNull Bundle state, @NonNull String key, @NonNull String[] fieldValue) {
    state.putStringArray(key, fieldValue);
}