Geek: Android Development ImageView Pictures cannot be displayed

Source: Internet
Author: User

Today comes a very strange question:

ImageView cannot display the loaded local sdcard picture in Android.

The process is: first call the local camera program camera, and then load the captured pictures in the ImageView display.

[Java]View Plaincopyprint?
  1. Public class Actienvi extends Activity {
  2. static final String TAG = "Actienvi";
  3. private static final int req_code_camera = 0x1;
  4. private String Imgpath = "";
  5. private String Tempath = "";
  6. @Override
  7. protected void OnCreate (Bundle savedinstancestate) {
  8. super.oncreate (savedinstancestate);
  9. Setcontentview (R.LAYOUT.ACTI_ENVI);
  10. ......
  11. }
  12. ......
  13. @Override
  14. protected void Onactivityresult (int requestcode, int resultcode, Intent data) {
  15. //Photo successful and return
  16. if (Requestcode = = Req_code_camera
  17. && ResultCode = = ACTIVITY.RESULT_OK) {
  18. This.imgpath = Tempath;
  19. Bitmap BM = bitmapfactory.decodefile (this.imgpath);
  20. Imgview.setimagebitmap (BM);
  21. Imgview.setscaletype (Scaletype.fit_center);
  22. }
  23. }
  24. .......
  25. //Call system camera to take pictures
  26. protected void Captureimage () {
  27. Intent Intent = new Intent (mediastore.action_image_capture);
  28. Tempath = Iohelper.generateimgpath ();
  29. File out = new file (Tempath);
  30. Intent.putextra (Mediastore.extra_output, Uri.fromfile (out));
  31. Startactivityforresult (Intent, Req_code_camera);
  32. }
  33. ......
  34. }

The feeling problem is more wonderful. Remember before doing a project, is also loading pictures, according to the comparison, found that the code logic, layout is no problem, the problem is where?

Search the internet for half a day, no results, feeling all caught on the edge of ... When I was about to give up, accidentally compared to the Androidmanifest.xml file, found slightly different, the difference lies in the users-sdk in the Android:targetsdkversion have and none. So I changed it.

[HTML]View Plaincopyprint?
    1. <uses-sdk android:minsdkversion="8" />
    2. <!--android:targetsdkversion= " --

I found the users-sdk in the Android:targetsdkversion commented out, and then debug the time, the picture actually shows. This is why AH??? Suddenly no words, ask the big God explain ah ...

http://blog.csdn.net/whucyl/article/details/9101563

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.