I can’t call Activity for minutes without a button

Asked

Viewed 25 times

0

Good afternoon, I’m starting to learn ansdroid, and I’m in the grip senguinte, I can’t do the screen change for minutes, where I’m missing and someone can give me an optimization?

public void passartelacategoria(View view) {
        final int MILISEGUNDOS = 3000;
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {

                Intent chamando = new Intent(MainActivity.this, categoriaActivity.class);
                MainActivity.this.startActivity(chamando);
                MainActivity.this.finish();
            }
        }, MILISEGUNDOS);
    }

1 answer

0

The code is correct, but probably by setting the time there in the method and also as the end, may be influencing.

Try declaring the weather up there in your Activity, for example:

public class MainActivity extends Activity {

    private static int TIME_OUT = 3000; 

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ...
}

Browser other questions tagged

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