Android sends broadcasts via ADB shell AM broadcast

Source: Internet
Author: User
Tags tagname

Android sends broadcasts via ADB shell AM broadcast

The following parameters for ADB shell AM broadcast are:


[-a <action>]
[-D ]
[-t <mime_type>]
[-C <CATEGORY> [-C <category>] ...]
[-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
[--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
[-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
[-n <component>]
[-f <flags>] [<uri>]

For example:

ADB shell am broadcast-a com.android.test--es test_string "This is test string"--ei Test_int +--ez Test_boolean True

Description: Blue is key, red is alue, string type, int type, Boolean type

DB shell AM Instrument [options] <COMPONENT>

Role: Initiates monitoring of the instrument instance.

parameters [Options]:

-e <key> <value>//-e options need to be placed before the-w option

Function: Provides a test option that exists as a key-value pair. Several key-value pairs are available in Android, as described in the following table.
Example:-E class Com.android.phone.fincomingcalltests#testrejectcall

-R

Function: Output test results in original form. This option is typically used with the-e perf true when performing a performance test.

Parameter <component>:

-W <test_package_name>/<runner_class>//<test_package_name> and <runner_class> Find in the androidmanifest.xml of the test project

Role: Keep adb shell open until test complete
Example:-W Com.android.phone.tests/com.android.phone.runners.functionaltestrunner

<key> <value> Reference Table

Keyvaluedescription
Package<java_package_name>the fully-qualified Java Package name for one of the packages in the test application. Any test case class, this uses the package name is executed. Notice that's not a Android package name; A test package had a single Android package name and may have several Java packages within it.
Class<class_name>the fully-qualified Java class name for one of the test case classes. Only the test case class is executed.
<class_name> #method Namea fully-qualified test Case class name, and one of the its methods. Only this method is executed. Note the hash mark (#) between the class name and the method name.
Functrueruns all test classes, that extend Instrumentationtestcase.
Unittrueruns All test classes This does not extend either instrumentationtestcase orperformancetestcase.
Size[small | medium | Large]runs A test method annotated by size. The annotations is @SmallTest, @MediumTest, and @LargeTest.
Perftrueruns all test classes, that implement Performancetestcase. When you use this option, also specify THE-R flag for AM instrument, so, the output was kept in raw format and not re- Formatted as test results.
Debugtrueruns tests in debug mode.
Logtrueloads and logs all specified tests, but does not run them. The test information appears in STDOUT. Use the verify combinations of other filters and test specifications.
Emmatrueruns a EMMA code Coverage analysis and writes the output to/data//coverage.ec on the device. To override the file location with the use Thecoveragefile key, which is described in the following entry.
Note:this option requires an emma-instrumented build of the test application, which you can generate with the coverage TA Rget.

Coveragefile<filename>
Overrides The default location of the ' EMMA coverage file ' on the device. Specify this value as a path and filename in UNIX format. The default filename is described in the entry for the Emma key

ADB shell am start [options] <INTENT>

Role: Initiate an activity

Example: ADB shell am start-a Com.lt.test.action.SECOND

Example: ADB shell am start-n com.lt.test/. MyActivity

Description: [options] and <INTENT> see http://developer.android.com/tools/help/adb.html#am

ADB shell am startservice [options] <INTENT>

Role: Start a service

Example: ADB shell am startservice-a Com.lt.test.action.ONESERVICE
Example: ADB shell am startservice-n com.lt.test/. MyService

ADB shell am force-stop <PACKAGE>
Role: Forcing an application to close

Example: ADB shell am force-stop com.lt.test

ADB shell am Broadcast [options] <INTENT>

Role: Send a broadcast
Example: ADB shell am Broadcast-a "action_finish" (sending a broadcast to close an activity)
Example: ADB shell am broadcast-a Android.intent.action.MASTER_CLEAR (Factory reset method, will erase all memory contents)

Example: ADB shell am broadcast-n com.lt.test/. Mybroadcast

ADB shell PM List packages [Options] <INTENT>

Role: List all package containing <INTENT>

Example: ADB shell pm List Packages com.lt

Description: [options] and <INTENT> see HTTP://DEVELOPER.ANDROID.COM/TOOLS/HELP/ADB.HTML#PM

Reference Links:

Http://developer.android.com/tools/help/adb.html

==========================================================================================

Extended reading:

The first part:

1. Ubuntu under Configuration environment anroid variable:

Execute sudo gedit/etc/profile on the terminal to open the text editor at the end of the append #set android environment

2. Run Eclipse and configure the Java environment variables

#set Java Environment

JAVA_HOME=/HOME/LOGINNAME/JDK Directory Name

JRE_HOME=/HOME/LOGINNAME/JDK Directory name/jre

Export path= $JAVA _home/bin: $JRE _home/bin: $PATH

Export classpath= $JAVA _home/lib: $JRE _home/lib: $CLASSPATH

Export Path=/home/loginname/android-sdk-linux_86/tools: $PATH

After saving, restart

3. Join the device ID to identify the current Android debugging environment

Add the device ID ID of the Android terminal in the/home/loginname/.android file

4. Updating the SDK

"Android Update SDK" Update SDK

5. Common commands:

"ADB help" for assistance

"ADB Get-serialno" gets the device string number

"adb root" gets root permission, which is useful for some phones, and most of the listed phones have turned this feature off. Root privileges can also be obtained through third-party tools such as pea clips.

"adb kill-server" kills ADB's server process.

"ADB start-server" starts the ADB server process.

"ADB devices" view the Android terminal that established the connection.

"Android List" displays all Android terminals

"Ddms" Start Ddms

"ADB remount" reloads the hard drive.

"ADB reboot" restarts the terminal.

"ADB install/path/appname" installation application

"ADB uninstall Com.android.helloworld" Uninstall HelloWorld, the system with the application cannot be uninstalled.

"ADB push/sourcepath/filename/destinationpath/filename" copies a file from the PC to the terminal

"ADB pull/sourcepath/filename/destinationpath/filename" copies a file from the terminal to the PC side

"ADB logcat-v time-s TAGNAME" displays the custom TAGNAME and displays the time

"ADB PPP" starts PPP via USB

"ADB monkey-p/path/appname-v 100" Force test of the program 100 times

The "adb shell" launches the shell command terminal on the PC side.

The above command requires the root authority of the PC (Tengyun technology ty300.com), when the command fails, you can try to switch the working directory to the SDK tools, for example: sudo./adb kill-server,sudo./adb start-server.

6. Shell commands, you can use the BusyBox toolset:

"AM Start-n {package name}/{package name}. {Active activity name} "Activate activity for an app, configure reference Androidmanifest.xml, such as alarm:
# AM Start-n Com.android.alarmclock/com.android.alarmclock.alarmclock

"AM broadcast-a android.intent.action.ActionName" sends a broadcast message

"SetProp Key Value" Sets the property value bit of key value

"Getprop Key" gets the property value of the key

"GetEvent" gets all events

"Watchprops" monitor the change of property value

"Stop SERVER" forcibly stops a service

"Start SERVER" starts a service

"IOCTL" control device

"Dumpsys Activity" displays event stack information

"Top" displays information such as resource usage for the instant process

"Free" shows current memory usage of the process

"PS" Displays the process's own identity information

"Rm/path/filename" Deletes a file from the terminal

"MkDir" Create a new directory or file

"grep" finds specific content

"LS" displays files in the current directory

"CD" Toggles the current directory

"chmod" Changing file properties

"CP" Copy File

"DD" Copy File

"MV" To move directory files, or rename

"Cat" View file contents

"Kill" kills the process

"ipconfig" View change network interface address and parameters

"Ping" detects network status

"Netstat" View network status

"Telnet" Log on to the remote host

"Sqlite3/path/databasename.db" opens a database. You can then use database operations commands such as Select,insert,delete

"Tcpdump-p-nnn-vvv-s 0-w/path/name.pcap port and TCP" network debug Grab Packet

"Gst-launch playbin Uri=file:///system/media/audio/bootaudio.mp3" GST multimedia frame, playing audio files

"Alsa_amixer" Audio Debug command, you can switch channels, adjust the volume, switch devices. The parameters of different chip manufacturers are set differently.

"Alsa_aplay-d Androidplayback_speaker_normal/cache/music/dial/0.wav" plays PCM stream via ALSA.

"Alsa_arecord" for recording with Alsa

"Am start-n com.android.music/com.android.music.mediaplaybackactivity-d/sdcard/bootaudio.mp3" starts Android process playback mp3

"Stack--symbols-dir=./out/target/product/name/symbols ramdump" View the call stack

"Exit" exits the shell

With the ADB shell, Cd/system/bin,ls can list out most of the available commands.

Manuscripts: Diligent Learning qkxue.net

Extended reading:

Http://qkxue.net/info/24437/Android-adb-shell-broadcast

Android sends broadcasts via ADB shell AM broadcast

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.