How do I get a button to open another activity?

A. Make sure your other activity is declared in manifest:


All activities must be declared in manifest, even if they do not have an intent filter assigned to them.

B. In your MainActivity do something like this:

Button btn = (Button)findViewById(;    

btn.setOnClickListener(new View.OnClickListener() {         
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, MyOtherActivity.class));

Leave a Comment