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.

2

1 Answer 1

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"/> 
Sign up to request clarification or add additional context in comments.

2 Comments

Why not add this as a comment?
how can you declare it in the manifest?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.