java 来自其他应用的图片选择器。字体:http://programmerguru.com/android-tutorial/how-to-pick-image-from-gallery/

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java 来自其他应用的图片选择器。字体:http://programmerguru.com/android-tutorial/how-to-pick-image-from-gallery/相关的知识,希望对你有一定的参考价值。

// Create intent to Open Image applications like Gallery, Google Photos
Intent galleryIntent = new Intent(Intent.ACTION_PICK,
		android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
// Start the Intent
startActivityForResult(galleryIntent, RESULT_LOAD_IMG);

//

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		try {
			// When an Image is picked
			if (requestCode == RESULT_LOAD_IMG && resultCode == RESULT_OK
					&& null != data) {
				// Get the Image from data

				Uri selectedImage = data.getData();
				String[] filePathColumn = { MediaStore.Images.Media.DATA };

				// Get the cursor
				Cursor cursor = getContentResolver().query(selectedImage,
						filePathColumn, null, null, null);
				// Move to first row
				cursor.moveToFirst();

				int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
				imgDecodableString = cursor.getString(columnIndex);
				cursor.close();
				ImageView imgView = (ImageView) findViewById(R.id.imgView);
				// Set the Image in ImageView after decoding the String
				imgView.setImageBitmap(BitmapFactory
						.decodeFile(imgDecodableString));

			} else {
				Toast.makeText(this, "You haven't picked Image",
						Toast.LENGTH_LONG).show();
			}
		} catch (Exception e) {
			Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG)
					.show();
		}

	}

以上是关于java 来自其他应用的图片选择器。字体:http://programmerguru.com/android-tutorial/how-to-pick-image-from-gallery/的主要内容,如果未能解决你的问题,请参考以下文章

CSS学习总结

CSS学习总结

CSS学习总结

如何在 Shiny 中更改选择器输入的字体大小?

pb中如何统一设置数据窗口字体大小

来自画廊工作的文件选择器,但它不适用于 android webview 中的相机