bvitaliyg
bvitaliyg

Reputation: 3255

Is it possible to implement such Activity behaviour?

There are two Activities: ActivityA and ActivityB.

From ActivityA I going to ActivityB. Then, I choose some list item and going back to Activity A(same instance) with selected data. And the most difficult: if I press back now, I should going back to ActivityB(with same instance and with saved View state).

Is it possible to implement? Not necessary via launchMode attribute, perhaps there is another way to manage Activities manually via ActivityManager.

Upvotes: 2

Views: 54

Answers (2)

Sanket Kachhela
Sanket Kachhela

Reputation: 10856

In onActivtyResult of Activity put boolean flag so that you can check that it comes after selecting data from Activity B and in onBackPressed of Activity A start Activity B

like this way

boolean flag = false;

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);
        flag = true;
    }

    @Override
    public void onBackPressed() {
        // TODO Auto-generated method stub

        if(flag)
        {
            //Start Activity B
        }
        else
        {
            // finish this activity
        }

    }

Upvotes: 2

AndRSoid
AndRSoid

Reputation: 1825

Use startActivityForResult to get the result from activity B which was started by activity A. Activity B returns result when it is finished.

Upvotes: 0

Related Questions