Java Code Examples for android.os.Bundle#putStringArrayList()

The following examples show how to use android.os.Bundle#putStringArrayList() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: kognitivo   File: BundleJSONConverter.java    License: Apache License 2.0 6 votes vote down vote up
public void setOnBundle(Bundle bundle, String key, Object value) throws JSONException {
    JSONArray jsonArray = (JSONArray)value;
    ArrayList<String> stringArrayList = new ArrayList<String>();
    // Empty list, can't even figure out the type, assume an ArrayList<String>
    if (jsonArray.length() == 0) {
        bundle.putStringArrayList(key, stringArrayList);
        return;
    }

    // Only strings are supported for now
    for (int i = 0; i < jsonArray.length(); i++) {
        Object current = jsonArray.get(i);
        if (current instanceof String) {
            stringArrayList.add((String)current);
        } else {
            throw new IllegalArgumentException("Unexpected type in an array: " + current.getClass());
        }
    }
    bundle.putStringArrayList(key, stringArrayList);
}
 
Example 2
@Test
public void getWithPurchasesNull() throws RemoteException {
    Bundle bundle = new Bundle();
    bundle.putLong(Constants.RESPONSE_CODE, 0L);
    bundle.putStringArrayList(Constants.RESPONSE_INAPP_SIGNATURE_LIST, new ArrayList<String>());

    Mockito.when(mService.getPurchases(
            mBillingContext.getApiVersion(),
            mBillingContext.getContext().getPackageName(),
            Constants.TYPE_IN_APP,
            null
    )).thenReturn(bundle);

    Purchases purchases = null;
    try {
        purchases = mGetter.get(mService, Constants.TYPE_IN_APP);
    } catch (BillingException e) {
        assertThat(e.getErrorCode()).isEqualTo(Constants.ERROR_PURCHASE_DATA);
        assertThat(e.getMessage()).isEqualTo(Constants.ERROR_MSG_GET_PURCHASES_DATA_LIST);
    } finally {
        assertThat(purchases).isNull();
    }
}
 
Example 3
Source Project: Klyph   File: UploadPhotoService.java    License: MIT License 6 votes vote down vote up
@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
	if (intent != null)
	{
		Message msg = mServiceHandler.obtainMessage();
		Bundle bundle = new Bundle();
		bundle.putStringArrayList(KlyphBundleExtras.UPLOAD_PHOTO_URIS,
				intent.getStringArrayListExtra(KlyphBundleExtras.UPLOAD_PHOTO_URIS));
		bundle.putString(KlyphBundleExtras.UPLOAD_PHOTO_CAPTION,
				intent.getStringExtra(KlyphBundleExtras.UPLOAD_PHOTO_CAPTION));
		bundle.putString(KlyphBundleExtras.UPLOAD_PHOTO_PLACE,
				intent.getStringExtra(KlyphBundleExtras.UPLOAD_PHOTO_PLACE));
		bundle.putString(KlyphBundleExtras.UPLOAD_PHOTO_PRIVACY,
				intent.getStringExtra(KlyphBundleExtras.UPLOAD_PHOTO_PRIVACY));
		bundle.putString(KlyphBundleExtras.UPLOAD_PHOTO_ALBUM,
				intent.getStringExtra(KlyphBundleExtras.UPLOAD_PHOTO_ALBUM));
		bundle.putStringArrayList(KlyphBundleExtras.UPLOAD_PHOTO_TAGS,
				intent.getStringArrayListExtra(KlyphBundleExtras.UPLOAD_PHOTO_TAGS));
		msg.setData(bundle);
		mServiceHandler.sendMessage(msg);	
	}

	// If we get killed, after returning from here, restart
	return START_STICKY;
}
 
Example 4
Source Project: MvpRoute   File: BaseExalpActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
	switch (v.getId()) {
		case R.id.base_image:
			LoginResponse loginResponse = new LoginResponse();
			loginResponse.setEmail("Dsadsadsa");
			Bundle bundle = new Bundle();
			BundleUtils.putObject(bundle,"test",loginResponse);
			ArrayList<String> list = new ArrayList<>();
			list.add("测试");
			list.add("看看");
			ArrayList<NoMessageBean> noMessageBeanArrayList = new ArrayList<>();
			noMessageBeanArrayList.add(new NoMessageBean("12",1));
			noMessageBeanArrayList.add(new NoMessageBean("13",1));
			bundle.putParcelableArrayList("nomessage", noMessageBeanArrayList);
			bundle.putStringArrayList("ni",list);
			Intent intent = new Intent(this, ImageActivity.class);
			intent.putExtras(bundle);
			startActivity(intent);
			break;
		default:

	}
}
 
Example 5
@Test
public void getItemDetailsJsonBroken() throws RemoteException, BillingException {
    int size = 10;
    ArrayList<String> itemIds = mDataConverter.convertToItemIdArrayList(size);
    ArrayList<String> items = mDataConverter.convertToSkuDetailsJsonBrokenArrayList();

    Bundle responseBundle = new Bundle();
    responseBundle.putLong(Constants.RESPONSE_CODE, 0L);
    responseBundle.putStringArrayList(Constants.RESPONSE_DETAILS_LIST, items);

    getItemDetails(
            itemIds,
            responseBundle,
            Constants.ERROR_BAD_RESPONSE,
            Constants.ERROR_MSG_BAD_RESPONSE
    );
}
 
Example 6
Source Project: MiBandDecompiled   File: h.java    License: Apache License 2.0 5 votes vote down vote up
public void run()
{
    int i = 0;
    while (i < a.size()) 
    {
        String s = (String)a.get(i);
        if (Util.isValidUrl(s) || !Util.fileExists(s))
        {
            continue;
        }
        android.graphics.Bitmap bitmap = com.tencent.connect.share.a.a(s, 10000);
        if (bitmap == null)
        {
            continue;
        }
        String s1 = (new StringBuilder()).append(Environment.getExternalStorageDirectory()).append("/tmp/").toString();
        String s2 = Util.encrypt(s);
        String s3 = (new StringBuilder()).append("share2qzone_temp").append(s2).append(".jpg").toString();
        if (!com.tencent.connect.share.a.a(s, 640, 10000))
        {
            Log.d("AsynScaleCompressImage", "not out of bound,not compress!");
        } else
        {
            Log.d("AsynScaleCompressImage", "out of bound, compress!");
            s = com.tencent.connect.share.a.a(bitmap, s1, s3);
        }
        if (s != null)
        {
            a.set(i, s);
        }
        i++;
    }
    Message message = b.obtainMessage(101);
    Bundle bundle = new Bundle();
    bundle.putStringArrayList("images", a);
    message.setData(bundle);
    b.sendMessage(message);
}
 
Example 7
Source Project: BlackList   File: SMSSendFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    ArrayList<String> numbers = new ArrayList<>(number2NameMap.keySet());
    ArrayList<String> names = new ArrayList<>(number2NameMap.values());
    outState.putStringArrayList(CONTACT_NUMBERS, numbers);
    outState.putStringArrayList(CONTACT_NAMES, names);
}
 
Example 8
Source Project: Onosendai   File: EnabledServiceRefs.java    License: Apache License 2.0 5 votes vote down vote up
public void addToBundle (final Bundle bundle) {
	if (bundle == null) return;
	synchronized (this.enabledRefs) {
		final ArrayList<String> arr = new ArrayList<String>();
		for (ServiceRef sr : this.enabledRefs) {
			arr.add(sr.toServiceMeta());
		}
		bundle.putStringArrayList(KEY_SREFS, arr);
	}
}
 
Example 9
Source Project: BusyBox   File: InstallerFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override public void onSaveInstanceState(Bundle outState) {
  super.onSaveInstanceState(outState);
  outState.putInt("path_index", pathIndex);
  outState.putStringArrayList("paths", paths);
  outState.putParcelableArrayList("binaries", binaries);
  outState.putParcelable("busybox", busybox);
  outState.putBoolean("uninstalling", uninstalling);
  outState.putBoolean("installing", installing);
  outState.putParcelable("download", download);
  outState.putParcelableArrayList("properties", properties);
  outState.putInt("download_complete_command", downloadCompleteCommand);
  outState.putBoolean("create_archive", createArchive);
}
 
Example 10
/**
 * Puts the list of declined permissions into a Bundle.
 *
 * @param bundle
 *            A Bundle in which the list of permissions should be stored.
 * @param value
 *            The List&lt;String&gt; representing the list of permissions,
 *            or null.
 *
 * @throws NullPointerException if the passed in Bundle or permissions list are null
 */
public static void putDeclinedPermissions(Bundle bundle, List<String> value) {
    Validate.notNull(bundle, "bundle");
    Validate.notNull(value, "value");

    ArrayList<String> arrayList;
    if (value instanceof ArrayList<?>) {
        arrayList = (ArrayList<String>) value;
    } else {
        arrayList = new ArrayList<String>(value);
    }
    bundle.putStringArrayList(DECLINED_PERMISSIONS_KEY, arrayList);
}
 
Example 11
Source Project: android   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Builds and returns a {@link Bundle} which contains a select subset of data in the
 * {@link MediaInfo}. Since {@link MediaInfo} is not {@link Parcelable}, one can use this
 * container bundle to pass around from one activity to another.
 *
 * @param info
 * @return
 * @see <code>toMediaInfo()</code>
 */
public static Bundle fromMediaInfo(MediaInfo info) {
    if (null == info) {
        return null;
    }

    MediaMetadata md = info.getMetadata();
    Bundle wrapper = new Bundle();
    wrapper.putString(MediaMetadata.KEY_TITLE, md.getString(MediaMetadata.KEY_TITLE));
    wrapper.putString(MediaMetadata.KEY_SUBTITLE, md.getString(MediaMetadata.KEY_SUBTITLE));
    wrapper.putString(KEY_URL, info.getContentId());
    wrapper.putString(MediaMetadata.KEY_STUDIO, md.getString(MediaMetadata.KEY_STUDIO));
    wrapper.putString(KEY_CONTENT_TYPE, info.getContentType());
    wrapper.putInt(KEY_STREAM_TYPE, info.getStreamType());
    if (!md.getImages().isEmpty()) {
        ArrayList<String> urls = new ArrayList<String>();
        for (WebImage img : md.getImages()) {
            urls.add(img.getUrl().toString());
        }
        wrapper.putStringArrayList(KEY_IMAGES, urls);
    }
    JSONObject customData = info.getCustomData();
    if (null != customData) {
        wrapper.putString(KEY_CUSTOM_DATA, customData.toString());
    }

    return wrapper;
}
 
Example 12
public static MenuListFragment newInstance(ArrayList<String> menus) {

        Bundle args = new Bundle();
        args.putStringArrayList(ARG_MENUS, menus);

        MenuListFragment fragment = new MenuListFragment();
        fragment.setArguments(args);
        return fragment;
    }
 
Example 13
Source Project: pay-me   File: IabHelperTest.java    License: Apache License 2.0 5 votes vote down vote up
private static Bundle createSkuDetailsResponseBundle(String... skus) {
    Bundle response = new Bundle();
    ArrayList<String> itemList = new ArrayList<String>(skus.length);
    for (String sku : skus) {
        itemList.add("{ \"productId\": \""+sku+"\" }");
    }
    response.putInt(RESPONSE_CODE, OK.code);
    response.putStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST, itemList);
    return response;
}
 
Example 14
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (itemsList.size() != 0) {
        outState.putStringArrayList("ItemsListStringArray", itemsList);
    }
}
 
Example 15
public void saveState(Bundle bundle) {
    if (mEnteringNames != null) {
        bundle.putStringArrayList(ENTERING_SHARED_ELEMENTS, mEnteringNames);
    }
    if (mExitingFrom != null) {
        bundle.putStringArrayList(EXITING_MAPPED_FROM, mExitingFrom);
        bundle.putStringArrayList(EXITING_MAPPED_TO, mExitingTo);
    }
}
 
Example 16
public static CreatePrivateGroupChatDialog newInstance(List<String> accounts) {
    CreatePrivateGroupChatDialog dialog = new CreatePrivateGroupChatDialog();
    Bundle bundle = new Bundle();
    bundle.putStringArrayList(ACCOUNTS_LIST_KEY, (ArrayList<String>) accounts);
    dialog.setArguments(bundle);
    return dialog;
}
 
Example 17
/**
 * 当SharedPreference中设置了加载启动项的值,则会查询启动Receiver,否则会直接返回一个空Bundle(查询为耗时操作,此方法会阻塞)
 */
public static @NonNull Bundle getStaticRegisteredReceiversOfBundleTypeForPackageName(@NonNull Context context,@NonNull String package_name){
    Bundle bundle=new Bundle();
    if(!SPUtil.getGlobalSharedPreferences(context)
            .getBoolean(Constants.PREFERENCE_LOAD_STATIC_LOADERS,Constants.PREFERENCE_LOAD_STATIC_LOADERS_DEFAULT)){
        return bundle;
    }
    PackageManager packageManager=context.getPackageManager();
    String[] static_filters=context.getResources().getStringArray(R.array.static_receiver_filters);

    for(String s:static_filters){
        List<ResolveInfo>list=packageManager.queryBroadcastReceivers(new Intent(s),0);
        if(list==null)continue;
        for(ResolveInfo info:list){
            String pn=info.activityInfo.packageName;
            if(pn==null)continue;
            ArrayList<String> filters_class=bundle.getStringArrayList(info.activityInfo.name);
            if(filters_class==null){
                filters_class=new ArrayList<>();
                filters_class.add(s);
                if(pn.equals(package_name))bundle.putStringArrayList(info.activityInfo.name,filters_class);
            }
            else{
                if(!filters_class.contains(s)) filters_class.add(s);
            }

        }
    }
    return bundle;
}
 
Example 18
Source Project: ChinaShare   File: QQShareImpl.java    License: MIT License 5 votes vote down vote up
public void shareToQzeon(String title, String content, String shareUrl,
                         String imgUrl) {
    final Bundle params = new Bundle();
    params.putInt(QzoneShare.SHARE_TO_QZONE_KEY_TYPE, QzoneShare.SHARE_TO_QZONE_TYPE_IMAGE_TEXT);
    params.putString(QzoneShare.SHARE_TO_QQ_TITLE, title);
    params.putString(QzoneShare.SHARE_TO_QQ_TARGET_URL, shareUrl);
    params.putString(QzoneShare.SHARE_TO_QQ_SUMMARY, content);
    params.putString(QzoneShare.SHARE_TO_QQ_APP_NAME, ShareManager.getAppName());
    ArrayList<String> list = new ArrayList<String>();
    if (!TextUtils.isEmpty(imgUrl)) {
        list.add(imgUrl);
    } else {
        if(!TextUtils.isEmpty(ShareManager.getDefShareImageUrl())){
            list.add(ShareManager.getDefShareImageUrl());
        }
    }
    params.putStringArrayList(QzoneShare.SHARE_TO_QQ_IMAGE_URL, list);
    mTencent.shareToQzone(mActivity, params, new IUiListener() {

        @Override
        public void onCancel() {
        }

        @Override
        public void onError(UiError e) {
            String message = mActivity.getString(R.string.share_fail) + " " + e.errorMessage;
            Toast.makeText(mActivity, message, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onComplete(Object response) {

        }

    });
}
 
Example 19
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putStringArrayList("checkedNames", checkedNames);
}
 
Example 20
Source Project: TLint   File: GalleryActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putString("mTmpFilePath", mTmpFilePath);
    outState.putStringArrayList("resultList", resultList);
    super.onSaveInstanceState(outState);
}