How to see the activity/fragment related to screen in android? - android

Have joined a new company and am new to android ui. What is the best way to see which activity in code relates to ui which am seeing in emulator or device?

Run the app on a device and make sure the device is connected to your machine. In your terminal, run:
adb shell dumpsys activity | grep -i 'resumedactivity\|focusedactivity'
This will output the name of the activity that is currently being displayed

Related

How to access Data Saver/Network settings using ADB commands?

trying to open Data Saver menu using ADB Commands in Android TV 9, Philips 2020. Philips covered stock Network menu using their own, so there is no way to enable/disable Data Saver as it was installed.
https://beebom.com/enable-data-saver-mode-android-tv/
https://source.android.com/devices/tech/connect/data-saver
Any help witch command I can try to display this menu or simply enable/disable Data Saver feature will be appreciated. I connected using ADB my TV with terminal in my PC already.
Commands like that works, no surprise:
adb shell am start -a android.settings.system
But when I tried to use more complex ones I get errors, nothing opens on the TV. I based on this doc - https://developer.android.com/reference/android/provider/Settings
adb shell am start -a android.settings.SETTINGS.system
Starting: Intent { act=android.settings.SETTINGS.system } Error: Activity not started, unable to resolve Intent { act=android.settings.SETTINGS.system flg=0x10000000 }
If there is a command to do so, I can map it later using Button Mapper, so it will be more user friendly in daily use.

how to enable Multi display feature on Android O

Did anyone tried Android multiple display feature which is new in Android O
Following steps which is not working for me
1.connect hdmi cable to mobile(not sure can use USB as well)
2.make device in root and give following command (expect app is installed)
and not seen that app is launching on secondary(Multiple display feature
) it's just reflecting mobile display as it is because connected hdmi cable
adb shell am start com.Chrome.Canary --display 1
Please suggest any other way or any command to make it work?
Android in general do mirroring when two displays are connected. Right now google has not enabled support for touch and display mapping on the two displays. But if you want to launch any activity on any of the two displays then the command adb shell am start "your_activity" --display display_id will launch your activity on that particular display id. If the above command doesn't launch your activity then you can use adb shell am stack start display_id "your activity". This will also work. But regarding touch, it will be mapped to the primary display (display id 0). As per google you can enable the mapping of touch in EventHub.cpp of Android source code but till now I haven't found it useful. Hope my answer helps you.
Ran using below procedure passed with dell monitor:
ADB shell can be used to call Activity Manager(am) for starting any system actions (or an activity).
The syntax:
adb shell am start [-n (component)] [-a (action)] [-t (mime type)] [-d (data_URL)]
examples:
1. For starting ‘Settings app’:
adb shell am start -n com.android.settings/.Settings
In the above-mentioned command, we set component(-n) to be settings in a specific format.
For starting ‘Gallery app’:
adb shell am start -t image/* -a android.intent.action.VIEW
In the above-mentioned command, we are setting action(-a) for opening the default app for gallery with mime type(-t) to be image/*
In general, for external display the ‘display_id’ starts from ‘1’ in an increasing order, final command to do multi display operation is
adb shell am start -n com.android.settings/.Settings --display 1
The above command will display ‘Settings’ app only in external display with display_id = 1. The primary display will be in the same mode as before executing the command.

Passing adb shell commands into IntelliJ Android Launcher

I am building an Android application that is designed to help with load testing. When the app launches we are sending extra values to the main activity so that we can control what kind of load each app executes. Currently, we are doing this, scripted, via the terminal using adb directly which is pretty straight forward:
adb shell am start -e key1 value1 -e key2 value2 -n bla.bla/bla.MainActivity
For debugging purposes, I'd like to be able to do this from IntelliJ but I don't see anything in my run configuration screen that let's me pass anything to adb. Is this possible?
Might be waaaaaay late on this one, but you can always try the BashSupport plugin on the IntelliJ Repo.

How to know whether service is running using adb shell in android

I want to know whether media player service (registers with media.player when device boots up) is running or not using adb shell. Is it possible?
I tried running ps command but no success.
As mentioned already, adb shell service list will only list system services.
As explained in Android Emulator: How can I get a list of services that are running, you can look for services created by apps by using
// List all services
adb shell dumpsys activity services
// List all services containing "myservice" in its name
adb shell dumpsys activity services myservice
If it returns something, it means the service is installed. To know if the service is currently started or stopped, look for app=ProcessRecord(...) or app=null respectively.
You can also do it Linux style with a simple
ps | grep myservice
while inside of your shell.
Try the command line
adb shell service list
I get a list of service names and their package names as well.
To simply check whether a specific service is running, use:
adb shell service check <service>
For example, adb shell service check media.player gives Service media.player: found if it's running and Service media.player: not found otherwise.
If you need more detail, try dumpsys <service>. For example, adb shell dumpsys media.player returns information about media.player's clients, open files, etc.
Finally, if you really need serious detail for debugging, try adb shell dumpsys activity services which shows what's going on from ActivityManager's point of view. This includes information about intents, create times, last activity time, bindings, etc., etc. You can redirect the output if you want to store it for later viewing/searching. It's typically rather lengthy.
For Android 10, list all currently running services:
adb shell dumpsys activity services | grep "ServiceRecord" | awk '{print $4}' | sed 's/.$//' | sort
To know whether an app process is running or not (background or foreground):
adb shell pidof <package.name>
It'll return empty string if process is not running else its pid.

how can i use 'adb shell' command to know application response or current activity

I have created a batch file that fires adb shell command to start activity, send events to enter text into username and password text fields & click login buttons to navigate to other activity(screen).
how can i know that application navigate to other activity or want to know the response that tell me if login successful or not using shell commands.
Thanks,
Bhushan
Dollop, where I work, provides a record-and-play-back tool for Android that will do the things you suggest and save you the hassle of interacting with low-level shell commands. (It is currently limited to running on Windows in communication with Android devices). It's easy to configure and use, requires no programming, runs against real devices (which do NOT have to be rooted) and automatically saves screenshots as it plays tests. I'd love to hear your feedback.
try to get process (ps aux | grep xxxxx ) information to know the activity running or not

Categories

Resources