Jeferson, eu to olhando a permissão na activity do Mapa
Activity do Mapa
public class MapaActivity extends AppCompatActivity {
private static final int REQUEST_PERMISSOES = 1;
private MapaFragment mapaFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mapa);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED
|| ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
String[] permissoes = {android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION};
requestPermissions(permissoes, REQUEST_PERMISSOES);
}
}
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
mapaFragment = new MapaFragment();
transaction.replace(R.id.frame_mapa, mapaFragment);
transaction.commit();
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == REQUEST_PERMISSOES) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED &&
grantResults[1] == PackageManager.PERMISSION_GRANTED) {
new Localizador(this, mapaFragment);
}
}
}
}
Aqui o método que eu eu chamo a activity
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.menu_enviar_notas:
new EnviaAlunosTask(this).execute();
break;
case R.id.menu_baixar_provas:
Intent vaiPraProvas = new Intent(this, ProvasActivity.class);
startActivity(vaiPraProvas);
break;
case R.id.menu_mapa:
Intent vaiParaMapa = new Intent(this, MapaActivity.class);
startActivity(vaiParaMapa);
break;
}
return super.onOptionsItemSelected(item);
}