android – Dialog appears only after it has been called.

Question:

Hi!

In my application, I have a Button , which when clicked, opens the device's camera so the user can take a picture:

@Override
public void onClick(View v) {
    //dialog da minha aplicação
    final ProgressDialog dialog = MobileUtils.getBasicProgressDialog(getBaseContext());

    // Cria uma intent para capturar uma imagem e retorna o controle para quem o chamou 
    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    ...
}

The application should show a Dialog before going to the camera, but it stays about 5 seconds, opens the camera, and the dialog is only shown on the way back. Is there a way to only open the camera AFTER the Dialog appears?

Answer:

This will call the camera after 15 seconds:

final Runnable runnable = new Runnable() {
    @Override
    public void run() {
        // Isto será chamdo após 15 segundos...
        Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    }
};
new Handler().postDelayed(runnable, 15000);
Scroll to Top