adb、package及activity

1.   adb

adb connect the phone reference: https://www.cnblogs.com/mind18/p/12592252.html, the III.5 section

1.1. Adb Introduction

  • ADB full name Andorid Debug Bridge. Debug is a tool. adb tool is a standard C / S structure, which allows a computer simulator instance or Android device connected for communication. It provides convenient operations for a variety of devices, such as installation and debugging applications.
  • Comprising the following parts:

  1.Client end, running on the development machine, that your development PC. Adb used to send commands.

  2.Daemon daemon running in commissioning equipment, namely commissioning phone or emulator.

  3.Server end, as a background process running on a development machine, that your development PC. PC used to manage the communications between the Client terminal and mobile phones Daemon.

  • Communication between the three: Client <-> Server <-> Daemon

1.2. Works

  • When you start a adb client, the client first checks adb server process already running. If not, it starts the server process. When the server is started, it is bound to a local TCP port 5037 and listens for commands sent from adb client - all adb clients use port 5037 to communicate with the adb server.
  • At present, many PC clients connect adb Mobile Assistant is also based on the principle of the package.

1.3. Common command

1. View adb version number: adb Version

2. The connector Yagami simulator: the adb Connect 127.0.0.1:62001 port (Yagami simulator is regular, a first simulator port 62001 , the second simulator port 62025 , and the third is 62025+ 1 , and so on.)

a) simulator 1: Android 4.4.2 Address: 127.0.0.1:62001

b) simulator 2: Andriod 5.1.1 Address: 127.0.0.1:62025

3. The acquisition device number (to see if the device is successfully connected to): adb Devices

4. Get system version: the adb -s device number shell getprop ro.build.version.release

5. adb shell (mobile phone shell command line): enter adb shell has two states show after: # representatives have root privileges, $ representatives did not root privileges

6. install app to your phone:

Ø   the adb the install path /xx.apk (default installation)

Ø   the adb the install -R & lt path /xx.apk (cover mounting)

Ø   the adb -s 127.0.0.1:62001 the install path /xx.apk (designated installation)

In case of error: Failure [INSTALL_FAILED_INVALID_URI] , Solution: cmd following command line commands: first, the adb the remount ; a second step, the adb the shell ; a third step, CD / Data ; fourth step, the chmod 777 local ; re-install APK , the ok up.

7. Uninstall phone App :

Ø   first entering the device / data / app directory to find the app package name

adb shell

cd /data/app/

Ø   execute commands to delete

Uninstall com.wandoujia.phoenix2 adb (package name system after the installation will add end -1 numbers and the like, to be removed before they can successfully uninstall the software title for the package name without the .apk )

Uninstall adb | -k <apkName> (plus -k parameter , to uninstall the software but retains the configuration and cache files)

8. Check to install the equipment above the application package name: adb shell Package Penalty for PM List

9. acquire app boot package and start name ( phone you need to open the corresponding app) :

Mac/Linux: 'adb shell dumpsys window windows | grep mFocusedApp’

In Windows running Terminal 'adb shell dumpsys window Windows | findstr mFocusedApp '

10. get app start-up time: adb shell -W AM Start package name / start name

示例:adb shell am start -W com.yly.drawpic/.MainActivity

Explained: TotalTime : App own start-up time; WaitTime : boot time application

11. File Read Write:

Ø   send files to your phone: adb the Push computer terminal file path path phone midrange storage

示例:adb push C:\Users\win\Desktop\xx.png /sdcard

Ø   pull files from your phone to your PC : adb pull path phone side file computer terminal storage file path

Example: adb pull /sdcard/xx.png C: \ the Users \ win \ Desktop

Ø   Note: Due to rights issues, not directly pull the computer disk root directory, otherwise it will error:

C:\Users\Shuqing>adb pull /sdcard/server.log  D:\\

adb: error: cannot create file/directory 'D:\\': No such file or directory

12. Screenshot:

$ adb shell screencap /sdcard/screen.png

adb pull /sdcard/screen.png  C:\Users\Shuqing\Desktop

13. Check the phone logs run: adb logcat

14. The adb service startup and shutdown:

the kill-Server adb (closed adb service)

Start-Server adb (open adb service)

If 5037 port is occupied can use the following command to release the port

Ø  C:\Users\Shuqing> netstat -ano | findstr "5037"

TCP    127.0.0.1:5037         0.0.0.0:0              LISTENING       11072

TCP    127.0.0.1:5037         127.0.0.1:59519        TIME_WAIT       0

Ø  taskkill -f -pid XXX

15. The adb help: adb -help

2.   package和activity

2.1.  package

  • app in this Package is unique in doing app automation, we need to know Package. Note: .apk package and different name.
  • Package Access:

  A. By UIAuto can get the package name of a different app.

  B. Application package name to view the installation of the above: adb shell pm list package

  C. Get the app startup package name and start name (phone you need to open the corresponding app):

   Mac/Linux: 'adb shell dumpsys window windows | grep mFocusedApp’

   Windows 终端: 'adb shell dumpsys window windows | findstr mFocusedApp’

2.2.  activity

1 Introduction:

  • In Android, activity is the root of all programs, all programs are running processes in the activity, activity can be regarded as the most frequently encountered by the developer, which is also one of the most basic module android.
  • In the android program, activity generally represents a screen phone screen. If the phone compared to a browser, then the activity is equivalent to a web page. In the activity of which can add some Button, Checkbox and other controls, you can see the concept and the concept of activity pages quite similar.
  • Usually a android application is composed of a plurality of activity, you can jump to each other between a plurality of activity. For example, a Button button is pressed, may jump to other activity, and the page jump is slightly different, it is possible to jump between the activity return value.

2, activity life cycle:

  • "Generate, run, destroy," but this one will call many methods onCreate (creation), onStart (activated), onResume (recovery), onPause (pause), onStop (stop), onDestroy (destroyed), onRestart (restart).

3, Activity obtain:

  • Research and development to provide
  • Aapt (t ie Android Asset Packaging Tool,. This tool can be viewed in the SDK build-tools directory, create, update document attachment ZIP format (zip, jar, apk). Can also be resource files compiled into binary files), get command as follows:

   aapt dump badging xxxx.apk

   aapt dump badging xxxx.apk | find "launchable-activity"

 

 

Guess you like

Origin www.cnblogs.com/mind18/p/12656352.html