• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps AlertDialog with Intents

AlexeyS

Newbie
Hello. I created AlertDialog and have a problem with Negative Button Click. When i clicked it, i get an Fatal Error, i mean i have a problem with intent1. Thank you

Code:
public void onClick(DialogInterface dialog, int which) {
 
  switch(which) {
    case DialogInterface.BUTTON_POSITIVE:

    Intent intent = new Intent (this, A.class);
    startActivity(intent);
    break;

    case DialogInterface.BUTTON_NEGATIVE:

    Intent intent1 = new Intent (this, A.class);
    startActivity(intent1);
    break;
  
   }

}
 
Last edited by a moderator:
Hi. Welcome to Android Forums.

If your application crashed it would have generated a stack trace in the Logcat output. Please post the stack trace.
 
Hi, i solved this issue, but i don't understand the solution :)
Let's assume, we have four Activities, From A i pass to C, and from B i pass to C or D. in the C i can pass to A . When i passed from B to D it worked wonderful, but when i passed from B to C, it crashed. what i did, i added put extra in B to C, and wrote put extra("from"); and now it's work. What happened? Can you explain me please and if this right solution? Thank you
 
Difficult to understand the situation from your description.
If you can narrow down the problem area, and post the following, it would give people a better chance of answering your question:

- Relevant code sections
- Stack trace, if the application crashed

Thanks.
 
Back
Top Bottom