• 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
Mar 16, 2017
20
2
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, 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
 
Upvote 0
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.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones