IsActivePackage Method

Applies to TestComplete 15.64, last modified on May 16, 2024
The information below concerns legacy mobile tests that work with mobile devices connected to the local computer. For new mobile tests, we recommend using the newer cloud-compatible approach.


Checks if a package is currently active on the device.



PackageManagerObj An expression, variable or parameter that specifies a reference to a PackageManager object
Package [in]    Required    The PackageObject object.    
Result Boolean

Applies To

The method is applied to the following object:


The method has the following parameter:


Specifies the PackageObject object that corresponds to the package to be checked.

Result Value

Returns True if the specified package is currently active, and False otherwise.


The application is considered active as long as it is running. Most Android applications go into the background when you press the back or home button, so an application will be considered active unless you close it. You can close an application in the following way:

  • Launch the recent applications menu

    The way you open this menu varies on different devices. Usually, you need to long press the home button, or tap the menu button.

  • Swipe the required application so that it disappears.

    On most devices, you swipe up or right-swipe to do this.

This should close most applications.

If your application is still considered active, execute the Device.ShellExecute("am force-stop <package_name>") command from scripts.


The code below checks if the specified package is currently active on the device and posts an informative message to the test log:

JavaScript, JScript

function CheckPackage()

var pack = Mobile.Device("VirtualBox").PackageManager.InstalledPackage(0);
if (Mobile.Device("VirtualBox").PackageManager.IsActivePackage(pack))
  Log.Message("The specified package is active.")
  Log.Message("The specified package is not active.")



def CheckPackage():
  pack = Mobile.Device("VirtualBox").PackageManager.InstalledPackage(0)
  if (Mobile.Device("VirtualBox").PackageManager.IsActivePackage(pack)):
    Log.Message("The specified package is active.")
    Log.Message("The specified package is not active.")


Sub CheckPackage

Set pack = Mobile.Device("VirtualBox").PackageManager.InstalledPackage(0)
If Mobile.Device("VirtualBox").PackageManager.IsActivePackage(pack) Then
  Log.Message "The specified package is active."
  Log.Message "The specified package is not active."
End If

End Sub


procedure CheckPackage();
var pack;

pack := Mobile.Device('VirtualBox').PackageManager.InstalledPackage(0);
if (Mobile.Device('VirtualBox').PackageManager.IsActivePackage(pack)) then
  Log.Message('The specified package is active.')
  Log.Message('The specified package is not active.')

C++Script, C#Script

function CheckPackage()

var pack = Mobile["Device"]("VirtualBox")["PackageManager"]["InstalledPackage"](0);
if (Mobile["Device"]("VirtualBox")["PackageManager"]["IsActivePackage"](pack))
  Log["Message"]("The specified package is active.")
  Log["Message"]("The specified package is not active.")


See Also

LaunchPackage Method
InstallPackage Method
PackageManager Object

Highlight search results