2
I’m having a problem, take the Layout of Android Studio Navigation Drawer to do my project, but when I want to call the camera class the error.
I created another class for the camera, where I have verification of the GPS and the location where the image will be stored.
public class Camera extends Principal
{
private AlertDialog alerta;
public static final int IMAGEM_INTERNA = 1313;
public void Tirafoto (View view)
{
LocationManager locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
final boolean GPSEnabled = locationManager.isProviderEnabled
(LocationManager.GPS_PROVIDER);
if (GPSEnabled) {
Intent camera = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(camera, IMAGEM_INTERNA);
} else {
AlertDialog.Builder alertas = new AlertDialog.Builder(this);
alertas.setTitle("Ligar GPS");
alertas.setMessage("Para usar essa função você deve ativar seu GPS");
alertas.setPositiveButton("Ativar GPS", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
}
});
alertas.setNegativeButton("Não Ligar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
Toast.makeText(Camera.this, "Camera disponivel somente com o
uso do GPS=" + arg1, Toast.LENGTH_SHORT).show();
}
});
alerta = alertas.create();
alerta.show();
}
}
}
And in Main Activity I have
if (id == R.id.nav_camera) {
Camera camera = new Camera();
I do not know how to continue, because I tested several ways but I could not make it work.
I know it may just be a "draft" or I don’t know what, but I point out to you to check some spelling errors in a few words of your code.
– João Victor Gomes Moreira
Yes, and just a draft before putting in my correct design, but I don’t understand where there are spelling errors.
– Juliano Morche
Camera available only with GPS Usu
– João Victor Gomes Moreira