App API
Please read the Material Usage Rules on this site.
Description
IDroidAppAPI App
Gives you access to manage apps on your device. With this interface you can install, uninstall, open, and close apps, as well as perform other app-related actions.
Most methods often need a packageName parameter — this is the app's name, which helps to identify and manage the right app. To find an app's package name, you can use the Installed Apps tool.
This follows the same logic as the App Actions block for the Lite/Pro and Enterprise versions.
Properties
- Name of the current open app.
string Top { get; }
- Unique ID of the active Android process.
uint TopPid { get; }
Examples:
var app = instance.DroidInstance.App;
string top = app.Top;
uint TopPid = app.TopPid;
Methods
Open an app
void Open(string packageName)
Parameters:
string packageName // App name for this method to work.
Overload:
string activityName // Activity to launch for the app.
Example
//#1
var app = instance.DroidInstance.App;
var packageName = "com.google.chrome"; // App name
app.Open(packageName); // Open the app
//#2
var app = instance.DroidInstance.App;
var packageName = "com.google.chrome"; // App name
var activity = ".MainActivity"; // Chrome's main activity (not a working example!)
app.Open(packageName, activity); // Open app with specific activity
Open an app with a specific URL
void OpenUrl(string url, string packageName)
Parameters:
string url // URL to open.
string packageName // App name for this method to work.
Example
var app = instance.DroidInstance.App;
var packageName = "com.google.chrome"; // App name
var url = "http://ya.ru";
app.OpenUrl(url, packageName); // Open Chrome and go to ya.ru
Close a specific app
void Close(string packageName)
Parameters:
string packageName // App name for this method to work.
Example
var app = instance.DroidInstance.App;
var packageName = "com.google.chrome"; // App name
app.Close(packageName); // Close the app
Close all apps
void CloseAll()
Example
var app = instance.DroidInstance.App;
app.CloseAll(); // Close all apps
Clear app data
void Clean(string packageName)
This makes the app as fresh as after installation.
Parameters:
string packageName // App name for this method to work.