title: Android: Button doesn't work, but code doesn't show any error
body: <p>I'm trying to create a form to capture data, I need to access the camera to take pictures. My problem is when I try to call the camera with <code>imagenButton</code>, it's not working but the code doesn't show any error.</p>
  <p>Here's my <code>fragment</code> to declare form:</p>
  <pre><code>public class EspecimenesInsertarFragment extends Fragment implements 
  Response.Listener&lt;JSONObject&gt;, Response.ErrorListener {
  private EspecimenesViewModel especimenesViewModel;
  RequestQueue rq;
  JsonRequest jrq;
  
  final int COD_SELECCIONA=10;
  final int COD_FOTO=20;
  
  private static final int REQUEST_IMAGE_CAMERA=101;
  private static final int REQUEST_PERMISSION_CAMERA=101;
  
  Button btnGuardar, btnCancelar;
  ImageButton btnCamara, btnGaleria;
  ImageView imageView;
  public static final int MY_DEFAULT_TIMEOUT = 50000;
  
  
  public EspecimenesInsertarFragment() {
      // Required empty public constructor
  }
  
  public static EspecimenesInsertarFragment newInstance() { return new EspecimenesInsertarFragment();
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      // Inflate the layout for this fragment
  
      View view;
      view = inflater.inflate(R.layout.fragment_colecciones_insertar, container, false);
      imageView = (ImageView)view.findViewById(R.id.imageView);
      btnCamara=(ImageButton) view.findViewById(R.id.tomarFoto);
      btnGuardar = (Button) view.findViewById(R.id.buttonIngresarEspecimenes);
      rq = Volley.newRequestQueue(getContext());
  
  
    /*  if(validaPermisos()){
          btnCamara.setEnabled(true);
      }else{
          btnCamara.setEnabled(false);
      } */
  
      if (ContextCompat.checkSelfPermission(getContext(), WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED &amp;&amp;
              ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
          ActivityCompat.requestPermissions(getActivity(), new String[]{WRITE_EXTERNAL_STORAGE,
                  Manifest.permission.CAMERA}, 1000);
      }
  
  
      btnGuardar.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              registrar_especimen(&quot;http://localhost/BIO-UES-APP/EspecimenesController.php&quot;);
          }
      });
  static final int REQUEST_TAKE_PHOTO=1;
  
  public void tomarFoto(View view){
      Intent takePictureInent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
      Log.d(&quot;entra&quot;,&quot;&quot;);
      if(takePictureInent.resolveActivity(getActivity().getPackageManager())!= null){
          File photoFile=null;
          try {
              photoFile=createImageFile();
          }catch (IOException ex){
  
      }
          if(photoFile!=null){
          Uri photoUri=FileProvider.getUriForFile(getActivity(),&quot;com.example.luvin.drawercero&quot;,photoFile);
          takePictureInent.putExtra(MediaStore.EXTRA_OUTPUT,photoUri);
          getActivity().startActivityForResult(takePictureInent,REQUEST_TAKE_PHOTO);
          }
      }
  }
  </code></pre>
  <p>And this is my XML layout:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  android:layout_width=&quot;match_parent&quot;
  
  android:layout_height=&quot;match_parent&quot;
  tools:context=&quot;.Especimenes.EspecimenesConsultarFragment&quot;&gt;
  
  &lt;!-- TODO: Update blank fragment layout --&gt;
  &lt;ScrollView
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:layout_alignParentStart=&quot;true&quot;
      android:layout_alignParentLeft=&quot;true&quot;
      android:layout_alignParentTop=&quot;true&quot;
      android:layout_alignParentEnd=&quot;true&quot;
      android:layout_alignParentRight=&quot;true&quot;
      android:layout_alignParentBottom=&quot;true&quot;
      android:layout_centerVertical=&quot;true&quot;
      android:layout_marginStart=&quot;5dp&quot;
      android:layout_marginLeft=&quot;5dp&quot;
      android:layout_marginTop=&quot;0dp&quot;
      android:layout_marginEnd=&quot;-7dp&quot;
      android:layout_marginRight=&quot;-7dp&quot;
      android:layout_marginBottom=&quot;9dp&quot;
      tools:layout_editor_absoluteX=&quot;393dp&quot;
      tools:layout_editor_absoluteY=&quot;79dp&quot;&gt;
  
      &lt;LinearLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:orientation=&quot;vertical&quot;&gt;
  
          &lt;FrameLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:orientation=&quot;vertical&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;&gt;
  
              &lt;ImageButton
                  android:id=&quot;@+id/tomarFoto&quot;
                  android:layout_width=&quot;90dp&quot;
                  android:layout_height=&quot;90dp&quot;
                  android:layout_marginStart=&quot;100dp&quot;
                  android:layout_marginLeft=&quot;16dp&quot;
                  android:layout_marginTop=&quot;8dp&quot;
                  android:layout_marginEnd=&quot;24dp&quot;
                  android:layout_marginRight=&quot;24dp&quot;
                  android:clickable=&quot;true&quot;
                  android:src=&quot;@android:drawable/ic_menu_camera&quot; /&gt;
  
              &lt;ImageButton
                  android:id=&quot;@+id/seleccionarDesdeGaleria&quot;
                  android:layout_width=&quot;90dp&quot;
                  android:layout_height=&quot;90dp&quot;
                  android:layout_marginStart=&quot;200dp&quot;
                  android:layout_marginLeft=&quot;16dp&quot;
                  android:layout_marginTop=&quot;8dp&quot;
                  android:layout_marginEnd=&quot;24dp&quot;
                  android:layout_marginRight=&quot;24dp&quot;
                  android:src=&quot;@android:drawable/ic_menu_gallery&quot; /&gt;
  
  
          &lt;/FrameLayout&gt;
          
          &lt;androidx.constraintlayout.widget.ConstraintLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;88dp&quot;
              android:orientation=&quot;vertical&quot;&gt;
  
              &lt;Button
                  android:id=&quot;@+id/buttonCancelarEspecimenes&quot;
                  android:layout_width=&quot;129dp&quot;
                  android:layout_height=&quot;41dp&quot;
                  android:layout_toRightOf=&quot;@+id/buttonIngresar&quot;
                  android:backgroundTint=&quot;#96A6A8&quot;
                  android:gravity=&quot;center|left&quot;
                  android:text=&quot;CANCELAR&quot;
                  app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
                  app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                  app:layout_constraintHorizontal_bias=&quot;0.783&quot;
                  app:layout_constraintStart_toStartOf=&quot;parent&quot;
                  app:layout_constraintTop_toTopOf=&quot;parent&quot;
                  app:layout_constraintVertical_bias=&quot;0.659&quot; /&gt;
  
              &lt;Button
                  android:id=&quot;@+id/buttonIngresarEspecimenes&quot;
                  android:layout_width=&quot;129dp&quot;
                  android:layout_height=&quot;41dp&quot;
                  android:layout_marginStart=&quot;68dp&quot;
                  android:text=&quot;INGRESAR&quot;
                  app:backgroundTint=&quot;#00BCD4&quot;
                  app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
                  app:layout_constraintEnd_toStartOf=&quot;@+id/buttonCancelar&quot;
                  app:layout_constraintHorizontal_bias=&quot;0.85&quot;
                  app:layout_constraintStart_toStartOf=&quot;parent&quot;
                  app:layout_constraintTop_toTopOf=&quot;parent&quot;
                  app:layout_constraintVertical_bias=&quot;0.659&quot; /&gt;
          &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
  
      &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>Logcat message when button is pressed:</p>
  <pre><code>com.example.luvin.drawercero D/ViewRootImpl@6731d38[MainActivity]: ViewPostIme pointer 1
  </code></pre>
  <p>To complete my question, I have the permissions in the manifest. I already tried to call the camera in another way, tried creating the method in the <code>MainActivity</code> to create the <code>OnClick</code> event in the XML Layout, but nothing works.<br>
  If anyone knows how to solve this issue please help.<br>
  Thanks.</p>