How to use appium to get the context of an already running app?

I have an android app A that invokes another android app B.

I want to write test that starts app A, click a button which opens app B.

I then want to click a button in app B. Which returns the focus to app A and sends it some data.

Is it possible to get the context of app B when it’s open by app A?

Usually I open an app myself and get it context from that.

like this:

AndroidDriver AndroidDriver = new AndroidDriver( "http://localhost:53761/wd/hub" , capabilitiesObj);

Appium’s Android portion is based on Uiautomator, which is designed to handle automating across different applications. You do not need to start a new driver for application B. Use the findElement methods and functions as you normally would.

You can test this out yourself. You can launch application B from application A manually, and if you run uiautomatorviewer (on your host machine), you will be able to retrieve UI information about application B.

Yes you can open app B from app A using appium

@Elad , i assume your app B is native app. If its a mobileWeb/Hybrid app then it will not work.