How to avoid clearing the data while switching activity

Hi,

I am trying to open two navigation apps and give them the same destination and compare their result while the navigation is ongoing (using Mock locations to create the route). The issue that I have is I launch the first app and get the total route time and then switch to the second app get the total route time, I wait for 5 minutes and then switch back to the first app and it seems the provided route is gone. It seems every-time I start the activity in the middle of my code it does clear the data from my app. Is there a method to prevent this from happening ?

I pass these in my caps:

desired_caps[‘dontStopAppOnReset’] = ‘true’
desired_caps[‘noReset’] = ‘true’

and for the switch activity I use :
driver.start_activity(‘com.google.android.apps.maps’,‘com.google.android.maps.MapsActivity’)

Is there a way to pass a parameter or a flag to start_activity to just resume the first app instead of clearing the data and start it?

@Mahyar try:


        Activity activity = new Activity("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
        activity.setStopApp(false);
        ((AndroidDriver) driver).startActivity(activity);
1 Like

@Aleksei Thanks. Do you know the Python version of it since I am using python-client.

It’s work…? I want to Test My Android App My App Have 7 Activity Can I Test My App All Activity In Appium.