Search code examples
androidmonkeyrunner

How to launch activity "ACTION_SYNC_SETTINGS" or "ACTION_ADD_ACCOUNT" using monkeyrunner (Python script)


I am trying to start activity ACTION_SYNC_SETTINGS or ACTION_ADD_ACCOUNT which are in package android.provider.Settings but, the problem is these activities do not start.

My code is given below, which works for launching activity "Settings" but when I change activity by ACTION_SYNC_SETTINGS or SYNC_SETTINGS ; ACTION_ADD_ACCOUNT or ADD_ACCOUNT_SETTINGS then it odes not work...

Although, I tried with package com.android.provider.Settings too, but it did not work.

The only result I get is:

Monkey Command: wake.

Monkey Command: wake.

Monkey Command: quit.

(I am working at API level 10 and 15)

Please can any one guide me...?

My Code:

import os, subprocess

import sys

import time

import random

import string

import re

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

device = MonkeyRunner.waitForConnection(99, "emulator-5554") 

package='com.android.settings'

activity='.Settings'

component_name=package + "/" + activity

device.startActivity(component=component_name) 

Solution

  • Try to use:

    component = 'com.android.settings/.accounts.AddAccountSettings'  
    

    This will open the "Add an account" window where you can choose from Corporate, Email and Google.

    Choosing Google will start a new activity: com.google.android.gsf.login/.AccountIntroUIActivity

    To go directly to the sign in screen, use:

    device.startActivity(component = 'com.google.android.gsf.login/.LoginActivity')