0

I have and Menu Manager apps. The first MainActivity will call the MenuActivity The MenuActivity will call the Add_New_DishActivity
The problem is, when in Menu I can return to Main by using System.exit(1) and finish()
However when I try to return from Add_New_Dish to Menu, there is an error System.exit(1) and finish()
I have tried to use finishActivity(1); and only finish() in Add_New_Dish, but it doesn't work.
Please take a look at my code:

In Main, I used this codes to call the Menu

...
Intent intent = new Intent(context,Menu.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
...

in Menu, I used this codes to return to Main

  public void homButton_OnClick()
    {
        System.exit(1);
        finish();
    }

in Menu, I used this codes to Call Add_New_Dish

 public void addDishButton_Onclick(String categoryName)
    {
        Intent addDishIntent = new Intent(context, AddDish.class);
       addDishIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        addDishIntent.putExtra("categoryName", categoryName);
        context.startActivity(addDishIntent);

    }

and this codes to return to Menu, where the errors display:

public void homeButton_OnClick()
    {

        System.exit(2);
        finishActivity(1);
       // finish();
    }
Linh
  • 57,942
  • 23
  • 262
  • 279
Long V
  • 11
  • 2

0 Answers0