0

I am trying to create a simple android app which clicks photo and saves the photo in gallery and then show it in imageview. I am using File class to save photo in a gallery.

At first, my targetSdkVersion and CompileSdkVersion was 29 and buildtoolsVersion was 29.0.0. When I try to debug the app at first it gives errors of Sources not found for 'Android API 29' and decompiled .class file,Bytecode version:52.0(java 8) in Looper.class. Then, I change the targetSdkVersion and CompileSdkVersion to 28 and buildtoolsVersion to 28.0.3 as Sources for Android API 28 was available. After doing that it gives an error(Source code does not the bytecode) in Looper.java file. Now I am stuck as what to do. Also I am using Android Studio 3.4.1

Camera Method

`private void open_camera() {
    Intent cam = new Intent();
    cam.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
    File pic_file = null;
    try{
        pic_file = Image_file();
    }catch (Exception e){
        e.printStackTrace();
    }
    cam.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(pic_file));
    //This is the point where I get the error.
    startActivityForResult(cam,1);
}

`

File Method

`File Image_file() throws IOException {
    String time = new SimpleDateFormat("yyyyMMss_HHmmss").format(new Date());
    String Image_Name = "Image"+time+"_";
    File Store_dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
    File image = File.createTempFile(Image_Name,".jpg",Store_dir);
   Image_loc = image.getAbsolutePath();
    return image;
}`

0 Answers0