title: Android camera crash api 25
body: <p>So I have an app that Snaps single pictures and display them, I have tested my app on api 22, 23, 24 and it works fine, however on api 25 the app start crashing when I try to launch the camera. This is the function I'm using:</p>
  
  <pre><code>public void takePhoto(View v) {
  
          Intent callCameraApplicationIntent = new Intent();
          callCameraApplicationIntent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
  
             File photoFile = null;
            try {
  
              photoFile = createImageFile();
  
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          if (photoFile != null) {
  
              callCameraApplicationIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
  
              startActivityForResult(callCameraApplicationIntent, ACTIVITY_START_CAMERA_APP);
          }
  
  }
  
  
  File createImageFile() throws IOException{
  
      // Create an image file name
      String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
      String imageFileName = "IMAGE_" + timeStamp + "_";
      File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
      File image = File.createTempFile(imageFileName,".jpg",storageDir);
  
      // Save a file: path for use with ACTION_VIEW intents
      mImageFileLocation = image.getAbsolutePath();
      return image;
  
  }
  </code></pre>
  
  <p>Stacktrace</p>
  
  <p>E/AndroidRuntime: FATAL EXCEPTION: main
                                                                               Process: se.umu.student.snapnconvert, PID: 13417
                                                                               java.lang.IllegalStateException: Could not execute method for android:onClick
                                                                                   at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
                                                                                   at android.view.View.performClick(View.java:5637)
                                                                                   at android.view.View$PerformClick.run(View.java:22429)
                                                                                   at android.os.Handler.handleCallback(Handler.java:751)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                   at android.os.Looper.loop(Looper.java:154)
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                                                Caused by: java.lang.reflect.InvocationTargetException
                                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                                   at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
                                                                                   at android.view.View.performClick(View.java:5637) 
                                                                                   at android.view.View$PerformClick.run(View.java:22429) 
                                                                                   at android.os.Handler.handleCallback(Handler.java:751) 
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                                   at android.os.Looper.loop(Looper.java:154) 
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:6119) 
                                                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 
                                                                                Caused by: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/se.umu.student.snapnconvert/files/Pictures/IMAGE_20170810_084644_1767543939.jpg exposed beyond app through ClipData.Item.getUri()
                                                                                   at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
                                                                                   at android.net.Uri.checkFileUriExposed(Uri.java:2346)
                                                                                   at android.content.ClipData.prepareToLeaveProcess(ClipData.java:845)
                                                                                   at android.content.Intent.prepareToLeaveProcess(Intent.java:8941)
                                                                                   at android.content.Intent.prepareToLeaveProcess(Intent.java:8926)
                                                                                   at android.app.Instrumentation.execStartActivity(Instrumentation.java:1517)
                                                                                   at android.app.Activity.startActivityForResult(Activity.java:4225)
                                                                                   at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
                                                                                   at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
                                                                                   at android.app.Activity.startActivityForResult(Activity.java:4183)
                                                                                   at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
                                                                                   at se.umu.student.snapnconvert.Main.takePhoto(Main.java:55)
                                                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                                                   at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
                                                                                   at android.view.View.performClick(View.java:5637) 
                                                                                   at android.view.View$PerformClick.run(View.java:22429) 
                                                                                   at android.os.Handler.handleCallback(Handler.java:751) 
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                                   at android.os.Looper.loop(Looper.java:154) 
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:6119) 
                                                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) </p>