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?
- Public class Actienvi extends Activity {
- static final String TAG = "Actienvi";
- private static final int req_code_camera = 0x1;
- private String Imgpath = "";
- private String Tempath = "";
- @Override
- protected void OnCreate (Bundle savedinstancestate) {
- super.oncreate (savedinstancestate);
- Setcontentview (R.LAYOUT.ACTI_ENVI);
- ......
- }
- ......
- @Override
- protected void Onactivityresult (int requestcode, int resultcode, Intent data) {
- //Photo successful and return
- if (Requestcode = = Req_code_camera
- && ResultCode = = ACTIVITY.RESULT_OK) {
- This.imgpath = Tempath;
- Bitmap BM = bitmapfactory.decodefile (this.imgpath);
- Imgview.setimagebitmap (BM);
- Imgview.setscaletype (Scaletype.fit_center);
- }
- }
- .......
- //Call system camera to take pictures
- protected void Captureimage () {
- Intent Intent = new Intent (mediastore.action_image_capture);
- Tempath = Iohelper.generateimgpath ();
- File out = new file (Tempath);
- Intent.putextra (Mediastore.extra_output, Uri.fromfile (out));
- Startactivityforresult (Intent, Req_code_camera);
- }
- ......
- }
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?
- <uses-sdk android:minsdkversion="8" />
- <!--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