0
Good night. I am trying to make a page just to request the necessary permissions and then forward users to another application activity, however I am not able to make after accepting the permissions it is forwarded, I have to go out and enter the application or rotate it to forward to the next page. I’m a layman in that language if anyone can help me, I’d appreciate it. Below the application code.
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
public class Inico extends AppCompatActivity {
TextView txtpermissao;
String[] appPermissoes = {
Manifest.permission.RECORD_AUDIO,
Manifest.permission.CAMERA
};
public static final int CODIGO_PERMISSOES_REQUERIDAS = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_inico);
txtpermissao = findViewById(R.id.txtpermissao);
if(verificarPermissoes()){
Intent intent = new Intent(this, SegundaActivity.class);
startActivity(intent);
}else {
txtpermissao.setText("Nem todas as Permissões Foram Abilitadas");
}
}
public boolean verificarPermissoes(){
List<String> permissoesRequeridas = new ArrayList<>();
for(String permissao : appPermissoes){
if(ContextCompat.checkSelfPermission(this, permissao) != PackageManager.PERMISSION_GRANTED) {
permissoesRequeridas.add(permissao);
}
}
if(!permissoesRequeridas.isEmpty()){
ActivityCompat.requestPermissions(this,
permissoesRequeridas.toArray(new String[permissoesRequeridas.size()]),
CODIGO_PERMISSOES_REQUERIDAS);
return false;
}
return true;
};
}```