Skip to main content

Dispose · Quit · Sessions

This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET

Start or end the session on a device. These call app_session.

Dispose​

public void Dispose()

Quits a device from DeviceBuilder.Start, whose session was opened for this using block. For one from Connect, closes the pipe and waits for mobium to exit, leaving the session in the daemon to whoever opened it.

Quit​

public void Quit()

Ends the session on the device and closes the connection. The teardown is the daemon's own: accessibility settings put back, a recording or route stopped, WebViews detached, the device-side server stopped, and the app Start launched, if any, stopped too. Quitting a session that is not open succeeds, and a second quit — a using block ending after an explicit one — does nothing. A program that exits without quitting or disposing has the sessions it started ended for it: mobium sees the client go.

Sessions​

public IList<IDictionary<string, object?>> Sessions()

The sessions open on the daemon, each with device, platform and driver.

Examples​

Start a session and launch the app fresh​

using var session = Device.Builder().App("com.android.settings").Start();
Console.WriteLine(session.Session);

The same call from the command line, mobium session start --app com.android.settings, printed on an Android 15 emulator:

session already open on emulator-5554 (android, uiautomator2); com.android.settings was launched fresh and is in the foreground

End it, putting back what it changed​

device.Quit();

The same call from the command line, mobium session end, printed on an Android 15 emulator:

session ended on emulator-5554; anything it changed for the session is put back; com.android.settings, which the session launched, was stopped

More examples​

End the session, putting back what it changed​

var dev = Device.Builder().App("com.android.settings").Start();
try { dev.Tap("text=Display"); }
finally { dev.Quit(); }

Let a using block quit the session​

using (var dev = Device.Builder().App("com.android.settings").Start())
{
dev.Tap("text=Display");
} // quit here

List the sessions open on the daemon​

foreach (var s in device.Sessions())
Console.WriteLine($"{s["device"]} {s["platform"]} {s["driver"]}");