I know that many people already sent questions similar to this. However, this is a little different.
I have to try to get the current activity from an android app, but it is not possible. Normally, I interact with the app and execute this: adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'. However, it always shows MainActivity. I checked the activity list on APK Info and this list is so little
So, there is some way to start a specific screen of apps similar to this?
Related
I want to add and remove google account from device. Programmatically I heard was difficult. I used following command to show screen to add an account, which is working. However, i am not able to find command which removes / manages accounts. Please suggest correct app/intent to launch from adb (or other alternate possibilities to remove account)
I have tried ACCOUNT_TYPES, EXTRA_ACCOUNT_TYPES etc. abd says - Activity not started, unable to resolve Intent
This command launches add account settings screen
adb shell am start -a android.settings.ADD_ACCOUNT_SETTINGS
In order to shorcut and go directly to the current activity page of Android I must first find the activity name, if it is a fragment I try to get the closest activity as possible. I use a few commands to find this info, like "adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'" or "adb shell dumpsys activity top". Unfortunately it seems that "adb shell uiautomator dump" has only the package name of the current activity in the xml file, so it is not useful. Is that possible for Culebra to record the activity name of the current activity and generate it's associated code when it is an activity and not a fragment, something like device.startActivity(component='...') ? This would be very helpful and will permit the play back of the generated script directly from the activity.
I think your idea may be very helpful to others so I decided to add this functionality to culebra v 10.3.4.
The context menu, now includes Generates a startActivity()
which generates a line like this in the output script (considering that in this example Calculator was the Activity on top of the stack)
device.startActivity('com.android.calculator2/.Calculator')
I am writing a series of automated tests for an android app using calabash-android and I need to be able to detect whether the android system keyboard is visible or not and (if possible) read some of the keys (i.e. if the return key says Done instead of Next or Enter). I know there is the keyboard_visible? commands for iOS but I have not been able to find anything similar for android.
Has anyone built their own functions to handle these instances?
there is a way to take a dump of the screens current contents on android using a tool called uiautomator from the android SDK. You can then check this for whatever you need to. It's not the most elegant solution but it might just work. Have a look at this post.
Calabash handling "Complete action using" dialog
windown_input_method = %x(adb -s #{ENV['ADB_DEVICE_ARG']} shell dumpsys window InputMethod | grep "mHasSurface")
windown_input_method.include?("isReadyForDisplay()=true")
This one returns true if keyboard is visible and false if not
ENV['ADB_DEVICE_ARG'] is environmental variable holding the device id of your android device connected. If you always run on one device, simply
windown_input_method = %x(adb shell dumpsys window InputMethod | grep "mHasSurface")
windown_input_method.include?("isReadyForDisplay()=true")
will do
I have a question about using ADB.
I know that this command:
adb shell dumpsys activity
can show me all the activities that are currently running on the device.
But I notice that sometimes, the intents appear like this:
Intent { ...some_intent/activity_name.... (has extras) }
I know that extras mean that the activity has been started with some sort of parameters passed to it (I may be wrong here, please correct me if I am).
So my question is, how can I get the extras of the intent/activity through ADB ?
The reason I need this is because I'm trying to launch an apk (that is installed on the phone) through ADB command, something like:
adb shell "su -c 'am start -n com.package.name/.ActivityName'"
That works and bring up the application. The application has a start screen (say we call it HomeActivity) and you have to click a button and make some selections (say SelectionActivity) and it will go to another screen (say ActionActivity). I want to be able to launch the apk and make it go straight to ActionActivity.
The application will crash if I try to launch the ActionActivity with am start command, I'm assuming this is because it requires parameters from the SelectionActivity screen.
This is why I'm trying to see what are the "extras" or parameters that the ActionActivity screen actually gets, so that I can do something like:
adb shell "su -c 'am start -n com.package.name/.ActionActivity -e param1 val1 -e param2 val2'"
Hope my question is clear.
Please correct me if I'm making a mistake somewhere.
Thanks in advance!
If I am understanding correctly, your target is to start the 'action' activity with correct intent but you don't know what kind of parameter information should be included, right?
The dumpsys command won't dump everything you want, so to simply achieve your target, you have 2 options (you should find one device which you can burn your own firmware into it):
Modify the dump method in AMS to print out more information
Modify the ActivityThread class source code to print out the detailed intent information
is there a simple way to stop a running application using ADB.
Szenario:
Working on App
Have a script which uploads, installs and starts App on change
Problem:
Currently running version gets killed (not shutdown), which make testing cleanup very hard. Option would be to "do cleanup in between", like after a certain time, but I would prefer to do it in the correct location (so like with the OS, as long as the App is still running, so need to save value, as soon as the OS tells me e.g. memory low or calls onDestroy, I want to save stuff)
Chris
I'm not aware of a way to do this. I was hoping there might be a way to send an intent to tell the app to exit using adb shell e.g.
adb shell am start -a [intent] -n [class]
However, I found that somebody asked this question on a Google forum but they haven't got an answer:
http://groups.google.com/group/android-platform/browse_thread/thread/3fd02d01c6c3b41a/56814e518503efd6