Biraj Zalavadia
Biraj Zalavadia

Reputation: 28484

How to minimize current activity and resume previous one?

During research I found this code.

public boolean onKeyDown(int keyCode, KeyEvent event)  
    {
         if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)
         {
            this.moveTaskToBack(true);

            return true;
         }
        return super.onKeyDown(keyCode, event);
    }

Calling Activity like this

Intent i = new Intent(this, ActivityTwo.class);
                                i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                i.putExtra("IN_ROOMID", roomId);
                                i.putExtra("IN_USERID", from);
                                startActivity(i);

But above code minimize entire application that I don't want actually.

What is my requirement?

Suppose I have two activities say ActivityOne.java and ActivityTwo.java.

ActivityOne -> calls -> ActivityTwo

If I press back button in ActivityTwo it should be minimize and ActivityOne should resume.

Hos to achieve this. Thanks. Biraj Zalavadia.

Upvotes: 0

Views: 845

Answers (1)

Farhan
Farhan

Reputation: 13390

As, there is no concept of minimize explicitly. you can make ActivityOne single instance, and from ActivityTwo, start ActivityOne, ActivityTwo by default will go in background (minimized). what say you?

Upvotes: 1

Related Questions