How to use currentActivityCommand method of io.appium.java_client.android.AndroidMobileCommandHelper class

Best io.appium code snippet using io.appium.java_client.android.AndroidMobileCommandHelper.currentActivityCommand

Run io.appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

StartsActivity.java

Source: StartsActivity.java Github

copy
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * See the NOTICE file distributed with this work for additional
5 * information regarding copyright ownership.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package io.appium.java_client.android;
18
19import static io.appium.java_client.android.AndroidMobileCommandHelper.currentActivityCommand;
20import static io.appium.java_client.android.AndroidMobileCommandHelper.currentPackageCommand;
21import static io.appium.java_client.android.AndroidMobileCommandHelper.startActivityCommand;
22
23import io.appium.java_client.CommandExecutionHelper;
24import io.appium.java_client.ExecutesMethod;
25
26public interface StartsActivity extends ExecutesMethod {
27    /**
28     * This method should start arbitrary activity during a test. If the activity belongs to
29     * another application, that application is started and the activity is opened.
30     * <p>
31     * Usage:
32     * </p>
33     * <pre>
34     *     {@code
35     *     Activity activity = new Activity("app package goes here", "app activity goes here");
36     *     activity.setWaitAppPackage("app wait package goes here");
37     *     activity.setWaitAppActivity("app wait activity goes here");
38     *     driver.startActivity(activity);
39     *     }
40     * </pre>
41     *
42     * @param activity The {@link Activity} object
43     */
44    default void startActivity(Activity activity) {
45        CommandExecutionHelper.execute(this,
46            startActivityCommand(activity.getAppPackage(), activity.getAppActivity(),
47                activity.getAppWaitPackage(), activity.getAppWaitActivity(),
48                activity.getIntentAction(), activity.getIntentCategory(), activity.getIntentFlags(),
49                activity.getOptionalIntentArguments(), activity.isStopApp()));
50    }
51
52    /**
53     * Get the current activity being run on the mobile device.
54     *
55     * @return a current activity being run on the mobile device.
56     */
57    default String currentActivity() {
58        return CommandExecutionHelper.execute(this, currentActivityCommand());
59    }
60
61    /**
62     * Get the current package being run on the mobile device.
63     *
64     * @return a current package being run on the mobile device.
65     */
66    default String getCurrentPackage() {
67        return CommandExecutionHelper.execute(this, currentPackageCommand());
68    }
69}
70
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)