android-image

Upload an Image from camera or gallery in WebView

∥☆過路亽.° 提交于 2019-11-26 08:08:49
问题 WebView in this app opens a page with upload button. Below is the code block that allows to open a dialog box to upload image from gallery or camera. Within my Activity I have: private WebView wv; //make HTML upload button work in Webview private ValueCallback<Uri> mUploadMessage; private final static int FILECHOOSER_RESULTCODE=1; @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { if(requestCode==FILECHOOSER_RESULTCODE) { if (null == mUploadMessage)

How to change the Tabs Images in the TabHost

牧云@^-^@ 提交于 2019-11-26 08:06:29
问题 I am using the TabHost in my application, I am using four Tabs in my application and I want to use the different Images in the TabHost when the Particular Tab is been Selected and not selected. I need to use to different Images for a particular tab each. When I Select any Tab the Image is little bright and when I switch to another Tab that bright Image becomes grey shaded. I have implemented the TabHost but I don know how to change the Images in the TabHost. Can anybody help me in this.

How to display a list of images in a ListView in Android?

半世苍凉 提交于 2019-11-26 05:14:52
问题 How do I display a list of images using the ListView? I am downloading the images at run time. The total number of images is not fixed. 回答1: I'd start with something like this (and if there is something wrong with my code, I'd of course appreciate any comment): public class ItemsList extends ListActivity { private ItemsAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.items_list); this.adapter = new

How to get Bitmap from an Uri?

為{幸葍}努か 提交于 2019-11-26 03:15:35
问题 How to get a Bitmap object from an Uri (if I succeed to store it in /data/data/MYFOLDER/myimage.png or file///data/data/MYFOLDER/myimage.png ) to use it in my application? Does anyone have an idea on how to accomplish this? 回答1: . . IMPORTANT: See answer from @Mark Ingram below and @pjv for at better solution. . . You could try this: public Bitmap loadBitmap(String url) { Bitmap bm = null; InputStream is = null; BufferedInputStream bis = null; try { URLConnection conn = new URL(url)

Reading an image file into bitmap from sdcard, why am I getting a NullPointerException?

时光怂恿深爱的人放手 提交于 2019-11-26 03:07:30
问题 How can I read an image file into bitmap from sdcard? _path = Environment.getExternalStorageDirectory().getAbsolutePath(); System.out.println(\"pathhhhhhhhhhhhhhhhhhhh1111111112222222 \" + _path); _path= _path + \"/\" + \"flower2.jpg\"; System.out.println(\"pathhhhhhhhhhhhhhhhhhhh111111111 \" + _path); Bitmap bitmap = BitmapFactory.decodeFile(_path, options ); I am getting a NullPointerException for bitmap. It means that the bitmap is null. But I have an image \".jpg\" file stored in sdcard

Bitmap recycle with largeHeap enabled

倾然丶 夕夏残阳落幕 提交于 2019-11-26 02:57:49
问题 Before enabling largeHeap option, I was handling large bitmaps and it\'s consume almost the entire memory available for the application, and recycling it over navigation and loading new ones works round on almost the full heap available. However when some operations needs a bit more memory the application crashes. So I enabled largeHeap=true to have a bit more memory. But doing this has a unexpected behavior, it\'s looks like that recycle() method of bitmaps do not work most of times, and the

Out of Memory error with Bitmap

[亡魂溺海] 提交于 2019-11-26 02:24:49
问题 During runtime, I am trying to put an image in the surface view. When I tried using the image from the Drawable folder I got Out of memory error. After a quick search in the stackoverflow, I found that there will be some relief if we access the image from the asset folder. But still I get the Out of memory error during runtime. I have analyzed and found that scaling will help in resolving this kind of memory related issues. The thing is that I have the image size of 1280 x 720 and the device

About Android image and asset sizes

一笑奈何 提交于 2019-11-26 02:15:35
问题 I need to clarify some doubt about the image assets for my app, if I specify in an xml file that the height of something [image view] is 50 dip height which type of screen should i choose from the resources folder? drawable, hdpi, ldpi, mdpi, xhdpi, to have the 50 px height image, and what is the percentage for bigger, smaller size images compared to the base image, like in iOS, @2x, is literally 2 times the size of the image, and you say programatically the normal size, thanks! 回答1: mdpi is

How do I get the resource id of an image if I know its name?

时光总嘲笑我的痴心妄想 提交于 2019-11-26 00:46:33
问题 How do I get the resource id of an image if I know its name (in Android)? 回答1: With something like this: String mDrawableName = "myappicon"; int resID = getResources().getIdentifier(mDrawableName , "drawable", getPackageName()); 回答2: You can also try this: try { Class res = R.drawable.class; Field field = res.getField("drawableName"); int drawableId = field.getInt(null); } catch (Exception e) { Log.e("MyTag", "Failure to get drawable id.", e); } I have copied this source codes from below URL.

How to create a circular ImageView in Android? [duplicate]

穿精又带淫゛_ 提交于 2019-11-25 23:07:03
问题 This question already has answers here : How to make an ImageView with rounded corners? (46 answers) Closed 6 years ago . How could I create a rounded ImageView in Android? I have tried the following code, but it\'s not working fine. Code: Bitmap circleBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); BitmapShader shader = new BitmapShader (bitmap, TileMode.CLAMP, TileMode.CLAMP); Paint paint = new Paint(); paint.setShader(shader); Canvas c = new