0
Guys, I can’t find the reason why Android Studio does not recognize the method Uri.fromFile()
. I searched several places but nothing. My code is 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 strange thing is that Android Studio comes to suggest that I use this method, but when I use 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.