Well, I can not find out why Android Studio does not recognize the Uri.fromFile()
method. I researched in several places but nothing. My code looks like this:
foto.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent irParaCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
caminhoArquivo = getExternalFilesDir(null) + "/" + System.currentTimeMillis() + ".png";
File arquivo = new File(caminhoArquivo);
Uri localFoto = new Uri.fromFile(arquivo);
irParaCamera.putExtra(MediaStore.EXTRA_OUTPUT, localFoto);
startActivityForResult(irParaCamera, 123);
}
});
The strangest thing is that Android Studio even suggests that I use this method, but when I use it it does not recognize it. Follow the imports:
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import java.io.File;
Am I doing something wrong? Thanks in advance.