android - Set uri.parse resource as ImageView -
I am trying to set the image view as a resource for uri.pare.
I tried to do this work, but it is not working: failed to load image
Method 1:
Intent = intent (int. ACT_ATATACADATA); Intent.addCategory (Intent.CATEGORY_DEFAULT); Intent.setDataAndType (Uri.parse ("R.id.imageView1"), "image / *"); Intent.putExtra ("mimeType", "image / *"); Initialization (Intent.createChooser (intent, "set as:"));
Method 2:
intent to intent = new intent (); Intent.setAction (Intent.ACTION_VIEW); Intent.setDataAndType (Uri.parse ("R.id.imageView1"), "image / *"); StartActivity;
I can not set the imageview as a resource for uri.parse, so please help me how I set the form of URI as the source of the URF
I have a code, but I do not understand how this code adjusted with my code:
I found it:
ImageView imgView = (ImageView) findViewById (R.id.image3); ImgView.setImageURI (Uri.parse ("file: //mnt/sdcard/d2.jpg"));
How can I adjust it to my code:
intent.setDataAndType (Uri.parse ("R.id.imageView1"), "Image / *"); ImageView.setImageURI only takes Android content URI as described here:
In other words, it takes things like "file: //" or "content: //" URI, not what you want to do like a resource ID Are there.
If you want to do this, then the only way I know it, and what I did, was to write a resource in a file and then pass the image path to the ImageView URI. There are several instances of writing files in the system (including thinking about using SDCARD, etc.)
I am sure you can solve "Content: //" which is a ContentProvider Or "Content:" ContentProvider "File: //" plans using the OpenFile / openInputStream methods, but I left it before leaving it; I can eliminate it - if someone is curious how it works ... < / P>
Comments
Post a Comment