title: When displaying a picture from the gallery, the application breaks down
body: <p>sorry for my English.</p>
  
  <p>The application worked properly. attached the file to imageview and then it was sent to the server.</p>
  
  <p>And now after selecting a picture (file) the application displays it in the imageview all the methods work out correctly and to the end.</p>
  
  <p>But the application throws me to the previous fragment without any errors in the log.</p>
  
  <pre><code> @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if(resultCode == Activity.RESULT_OK &amp;&amp; requestCode == 100){
  
          if(getPath(data.getData()) != null){
  
          Uri fileUri = data.getData();
          file = new File(getPath(fileUri));
  
          String mimetype = getActivity().getContentResolver().getType(fileUri);
          Log.d("mylog","name " + file.getName() + " type " + mimetype);
  
          imageV.setVisibility(View.VISIBLE);
          imageV.setImageResource(R.drawable.icons8highpriority96);
  
          if(mimetype.equals("image/jpeg")){ imageV.setImageURI(fileUri);}
          if(mimetype.equals("image/png")){ imageV.setImageURI(fileUri);}
          if(mimetype.equals("application/pdf")){ imageV.setImageResource(R.drawable.icons8pdf80);}
          if(mimetype.equals("text/html")){ imageV.setImageResource(R.drawable.icons8doc80);}
  
          textFileName.setText(file.getName());
          textFileName.setVisibility(View.VISIBLE);
  
  
      }else {
              imageV.setVisibility(View.VISIBLE);
              textFileName.setVisibility(View.VISIBLE);
              textFileName.setText("Выберите файл из определенного раздела! ");}
  
      }
  
  }
  </code></pre>
  
  <p>I attach some of the logs that confuse me -</p>
  
  <pre><code>447-705/system_process I/ActivityManager: START u0 
  {act=android.intent.action.GET_CONTENT typ=*/* 
  cmp=com.android.gallery/com.android.camera.ImageGallery} from pid 
  1382
  201-304/? W/genymotion_audio: out_write() limiting sleep time 34149 
  to 23219
  201-304/? W/genymotion_audio: out_write() limiting sleep time 45759 
  to 23219
  201-304/? W/genymotion_audio: out_write() limiting sleep time 37369 
  to 23219
  447-705/system_process D/dalvikvm: GC_FOR_ALLOC freed 616K, 27% free 
  6910K/9424K, paused 5ms, total 5ms
  447-705/system_process D/dalvikvm: GC_FOR_ALLOC freed 755K, 31% free 
  6526K/9424K, paused 8ms, total 8ms
  447-544/system_process D/MobileDataStateTracker: default: 
  setPolicyDataEnable(enabled=true)
  201-304/? W/genymotion_audio: out_write() limiting sleep time 28979 
  to 23219
  447-540/system_process I/qtaguid: Failed write_ctrl(s 1 10016) 
  res=-1 
  errno=1
  447-540/system_process W/NetworkManagementSocketTagger: 
  setKernelCountSet(10016, 1) failed with errno -1
  1448-1448/com.android.gallery D/dalvikvm: GC_FOR_ALLOC freed 662K, 
  27% free 
  3596K/4900K, paused 2ms, total 2ms
  1448-1448/com.android.gallery D/dalvikvm: GC_FOR_ALLOC freed 527K, 
  28% free 
  3547K/4900K, paused 1ms, total 1ms
  201-304/? W/genymotion_audio: out_write() limiting sleep time 31767 
  to 23219
  1448-1448/com.android.gallery D/dalvikvm: GC_FOR_ALLOC freed 220K, 
  27% free 
  3613K/4900K, paused 1ms, total 1ms
  447-544/system_process D/MobileDataStateTracker: default: 
  setPolicyDataEnable(enabled=true)
  447-464/system_process I/ActivityManager: Displayed 
  com.android.gallery/com.android.camera.ImageGallery: +124ms
  1448-1448/com.android.gallery D/dalvikvm: GC_FOR_ALLOC freed 103K, 
  21% free 
  3915K/4900K, paused 2ms, total 2ms
  1448-1448/com.android.gallery D/dalvikvm: GC_FOR_ALLOC freed 265K, 
  16% free 
  4121K/4900K, paused 18ms, total 18ms
  1448-1448/com.android.gallery D/dalvikvm: GC_FOR_ALLOC freed 586K, 
  24% free 
  3748K/4900K, paused 3ms, total 3ms
  447-544/system_process D/MobileDataStateTracker: default:  
  setPolicyDataEnable(enabled=true)
  447-544/system_process D/MobileDataStateTracker: default: 
  setPolicyDataEnable(enabled=true)
  447-540/system_process I/qtaguid: Failed write_ctrl(s 0 10053) 
  res=-1 
  errno=1
  447-540/system_process W/NetworkManagementSocketTagger: 
  setKernelCountSet(10053, 0) failed with errno -1
  447-544/system_process D/MobileDataStateTracker: default: 
  447-539/system_process D/dalvikvm: GC_FOR_ALLOC freed 999K, 31% free 
  6545K/9424K, paused 4ms, total 5ms
  447-544/system_process D/MobileDataStateTracker: default: 
  setPolicyDataEnable(enabled=true)
  447-544/system_process D/MobileDataStateTracker: default: 
  setPolicyDataEnable(enabled=true)
  201-304/? W/genymotion_audio: out_write() limiting sleep time 44149 
  to 23219
  201-304/? W/genymotion_audio: out_write() limiting sleep time 55759 
  to 23219
  447-447/system_process D/dalvikvm: GC_FOR_ALLOC freed 444K, 27% free 
  6903K/9424K, paused 6ms, total 6ms
  447-447/system_process D/dalvikvm: GC_FOR_ALLOC freed 749K, 31% free 
  6525K/9424K, paused 5ms, total 5ms
  447-544/system_process D/MobileDataStateTracker: default: 
  setPolicyDataEnable(enabled=true)
  447-540/system_process I/qtaguid: Failed write_ctrl(s 1 10053) 
  res=-1 
  errno=1
  447-540/system_process W/NetworkManagementSocketTagger: 
  setKernelCountSet(10053, 1) failed with errno -1
  1382-1382/com.example.usersad.myapplication D/mylog: name 
  IMG_20180327_045230.jpg type image/jpeg
  </code></pre>
  
  <p>I copied my code into a new project and it works!
  both from activi and fragment.
  but in the main project after interaction with the gallery the fragment is closed.</p>