activity

package
v0.0.0-...-028fd47 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package activity provides useful methods to determine or handle activity on associated android device.

Following features are provided by this package :

  • Launch a new activity by canonical class name
  • Get currently focused activites canonical class name
  • Determine if certain activity is focused or not
  • Wait for an activity to get focused on device

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	// contains filtered or unexported fields
}

Activity struct represents activity subsystem for associated android device.

func NewActivity

func NewActivity(dev device.Device) Activity

NewActivity method gives an initialized instance of activity manager. It takes device.Device is a parameter and returns an instance of activity.Activity struct.

func (Activity) GetFocusedActivity

func (am Activity) GetFocusedActivity() (string, error)

GetFocusedActivity method provides currently focused activity on device screen. It uses adb command "dumpsys acyivity" command to determine focused activity and extracts package name from the line "mFocusedActivity". It returens error if something went wrong on adb side or the method is unable to determine the activity canonical package name.

func (Activity) IsActivityFocused

func (am Activity) IsActivityFocused(name string) (bool, error)

IsActivityFocused method checks if given activity is focused on device screen or not. If the currently focused activity canonical package contains given name then it returns true, and its not case sensitive in nature. It returns error if activity information can not be parsed or somethis else went wront in between.

func (Activity) StartActivity

func (am Activity) StartActivity(canonicalClass string, options ...string) error

StartActivity method launches a activity on device. See "am start" for more more details regarding this command. It takes canonilcal class name as its first parameter which defines the package and class name of the activity to be launched and a list of accepable options by am start command. This method requires root access on device and returns error if root access can not be granted. It also returns other adb related errors if something goes wrong.

TODO Check if activity can not be launched or not found or other command related outputs.

func (Activity) WaitForActivityToFocus

func (am Activity) WaitForActivityToFocus(name string, timeout int) error

WaitForActivityToFocus method waits for given activity name to be focused on device screen in given timeout period. If activity is not focused within timeout then error is returned. Also error is returned if something else went wrong such as adb error or current focused activity can not be determined. This method returns instantly when given activity is found to be focused on screen.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL