Dialog appears only after it has been called

Asked

Viewed 87 times

3

Hello!

In my application, I have a Button, that when clicked, opens the device’s camera so the user can take a photo:

@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 stops for about 5 seconds, opens the camera, and the dialog is only shown on the way back. There is a way to only open the camera after the Dialog turn up?

  • The only chance I see is for the camera to be called by/on Dialog.

  • I’ll study how to do it, post the answer when I get it!

  • 1

    Maybe if you change your approach and analyze the context, it’s the best option. The user clicked on a photo take button and you want to show an alert before it opens the camera. Doesn’t it make more sense to display the dialog with a "I got it" button and, by clicking this button, open the camera? Or still, it would not be better to extract this information to another part of the layout, which does not require a dialog?

  • In fact the dialog just displays a "wait", and it would only be to guide the user that the camera will open

1 answer

-1


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);
  • Who will use an app that takes 15 seconds to open the camera.

  • @ramaral, it is just an example, for him to be aware of the functioning!

  • really, here it works up to a delay of 1 second, but I find it uncertain that it will work always leaving a small delay

  • If in doubt, please follow the documentation: http://developer.android.com/intl/pt-br/reference/android/os/Handler.html

  • For now I’m using this approach, apparently a small delay is enough for him to open the dialog first, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.