Well, I have searched a lot. People say that I need to close the window of emulator to close it. However, I need to reboot the emulator to catch ACTION_BOOT_COMPLETED by my BroadcastReceiver.
How can I do that?
You can use the following command from adb:
adb shell am activity/service/broadcast -a ACTION -c CATEGORY -n NAME
for example:
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n package_name/class_name
Note that class name and package names need to be as defined in the Manifest.
This will generate the Intent you want , directed only to the component you want (otherwise you system will go crazy with BOOT_COMPLETED sent...)
Or another way (also from the command line):
adb shell stop
adb shell start
First, make sure that USB Debugging is enabled from within the emulator:
click:
the Home icon
Menu icon
'Settings'
'Applications'
'Development'
make sure that the box next to 'USB debugging' contains a check mark
from a command-line:
adb -e reboot
EDIT:
This definitely doesn't work... very strange. I tested it and could not make the emulator reboot. It just hangs.
To emulate a broadcast action, you can connect via adb to the emulator/device and open a shell:
adb shell
Then, you can broadcast the action you want to test:
am broadcast -a android.intent.action.BOOT_COMPLETED
Please note that, in the latest Android versions, broadcasting the *android.intent.action.BOOT_COMPLETED* action will actually reboot your emulator/device.
While using tubemate on android tab, I was not successful in downloading video with the error:host interupped etc. I used the following commands:
adb shell stop
adb shell start
and the application started downloading videos.
emulators have on/off button - just click it
and another way:
If you start your emulator, and select the "wipe user data" checkbox, you will also receive that notification when boot is completed.
Related
Does anyone know if there is a way to fire up a specific test from the GFXBench suite directly from adb shell?
I have seen references on the net about a very similar command:
adb shell am broadcast -a net.kishonti.testfw.ACTION_RUN_TESTS -n net.kishonti.gfxbench.vulkan.v50000.corporate/net.kishonti.benchui.corporate.CommandLineSession -e test_ids "gl_manhattan" --ei raw_config.single_frame 56400 --ei raw_config.max_rendered_frames 1 --es -screenshot_frames 0
but this does not seem to work with the current GFXBench application.
Maybe because you need to start the main activity first.
Have you tried
am start net.kishonti.gfxbench.vulkan.v50000.corporate/net.kishonti.app.MainActivity
Then sleep for a second to let the activity start, and then fire up the braodcast command
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.
I'm trying to find a way to enable the Developer options -> Stay awake option via ADB.
The solution that I found was to find a way to open developers option menu and then enable stay awake option using setevent command in ADB.
Now I'm trying to find the command that will open the developers options.
I found the command that opens display options:
adb shell am start -n com.android.settings/.DisplaySettings
So I think that a similar command that opens developers options exists.
I will also be glad to hear about another way to enable stay awake option via ADB if there is any.
adb shell am start -n com.android.settings/.DevelopmentSettings
You can enable Stay awake option without having to use UI with the following command:
adb shell settings put global stay_on_while_plugged_in 3
OK, I found a way:
adb shell am start -S com.android.settings/.Settings\$DevelopmentSettingsActivity
I used this : https://github.com/android/platform_packages_apps_settings/blob/master/AndroidManifest.xml
to find the name of the Activity I needed.
Now I have to figure out how to choose the stay awake option by createing a touch event or something...
Set the 'keep awake while plugged in' setting.
adb shell svc power stayon true
Okay I know it is not what MiSo was asking but I think it may be relevant, I have created an app that will enable/dissable this 'Stay awake' setting as you connect/disconnect ADB.
The code is available open-source here: ABD-Stay_Awake
try this:
setprop persist.sys.usb.config mtp,adb
I set one of the program as default launcher program and default setting program so I cannot change the default programs now, can I change the default programs from android-sdk\android-sdk\platform-tools\adb.exe or remote shell.
How can I do that?
And can I remove the defaults of program in Java code?
For system apps you can't uninstall, use pm disable as in
adb shell pm disable com.android.launcher
you can remove (Uninstall) the default program you set using ADB by doing this :
adb uninstall app.package ..... //for example (com.example.homeapp)
If you don't want to remove the app .. here is a quick hack to do it:
adb shell
am start -a android.intent.action.MAIN
That way you will have a picker with all apps on your devices that listens to Main Action
Choose any home screen app you want . then go to settings and set it as default.
adb shell cmd package set-home-activity "package/activity"
adb reboot
The key is adb. Once you know the package name of the app you wish to clear data for, try:
adb shell pm clear package.name.of.app
It'll clear all data for the app, but I don't know of a way to only clear the defaults.
You can check and change the default sms app by using adb shell settings get secure sms_default_application and then use adb shell settings put secure sms_default_application <package name>. I'm not sure about the other default apps, but it's just a matter of finding it with adb shell settings list <secure/system/global>
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.