You are here: Tools > Genymotion Java API > Using Genymotion Java API

Using Genymotion Java API

To use the Genymotion Java API in your Android test project, follow the steps below:

  1. Inside your Android test project, get a reference to the Genymotion object using:

    GenymotionManager genymotion = Genymotion.getGenymotionManager(getInstrumentation().getContext())

  2. Access sensors from the GenymotionManager.
    For example, to set the battery charge level, use the command below:

    genymotion.getBattery().setLevel(10);

This call freezes the application (10 seconds maximum) until the change is really effective.

You can find all available methods in Genymotion Java API Javadoc.

For more information about the Binocle application, you can refer to Binocle source code.