tags:

views:

33

answers:

2

I wanna run two system activities one after another in specific order.

now as we know, startActivity is an asynchronous operation, so i cant keep on a specific order.

so i thought maybe I should try to do it with dialogBox in the middle but also running a dialogBox is an asynchronous.

now as i said the activities which i try to run are system activities, so i cant even start them with startActivityForResult (or mybe i can, but i cant think how it will help me).

Any tricks how could i manage with this issue?

Some code:

first activity:

                                         Intent intent = new Intent();
                                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                           intent.setAction(Settings.ACTION_APPLICATION_SETTINGS);
                                           startActivity(intent);   

second activity:

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.fromFile(tmpPackageFile
            .getAbsoluteFile()),
            "application/vnd.android.package-archive");
    startActivity(intent);

as you can see, i dont have any access to those activites, i can just run thire intents from an outside class/activity/service.

A: 

You should be able to use startActivityForResult.. The second parameter to that function is a unique id, which you can use to track which activity is ending.

In onActivityResult of the calling activity, check which activity just finished, then start the next one with another call to startActivityForResult (or, if you don't care what happens with the 2nd, just startActivity).

Mayra
I have tried it.. but it didnt work, the onActivityResult never got called. as i said, this is not my activities, it's the system activities, no idea when they call thire finish(); method.
rayman
So what happens after you hit back from the activity? Does it return to your activity?
Mayra
A: 

I may be missing the boat on this, it seems you should place your code to start the second activity in the handler that finishes the first activity, such as on a button press or when an item is selected from a ListView. More information on how the first Activity is terminated would help.

cphil5
The first activity terminate(i think) as soon as you press back.. it's a system settings window.Could you write some example for this solution? thanks.
rayman