0

i try to make an intent which is used to go to a 2nd activity. however when i try to click on it, it makes my application crash.

here's the code:

public class MainActivity extends AppCompatActivity {
private Button mButtonCommande;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mButtonCommande=findViewById(R.id.buttonAccessCommande);
            mButtonCommande.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    openCommandeActivity();
                }
            });

    }

    public void openCommandeActivity() {//cette méthode me sert à envoyer vers l'activité commande
        Intent intent = new Intent(this, CommandeActivity.class );
        startActivity(intent);
    }

idk where it keeps crashing and i need help.

1 Answers1

1

Make sure you declared the target activity in AndroidManifest.xml. In your AndroidManifest.xml, add the following inside the <application> element:

<activity android:name=".CommandeActivity"/>
Rediska
  • 1,392
  • 10
  • 14