This article will introduce how to find PID of a package running via adb command.
1. "adb shell pidof PACKAGE_NAME"
The following command prints the pid of the com.google.android.youtube
package. 5862
is the PID of Youtube. But, note that nothing will be output if the app is not running.
$ adb shell pidof com.google.android.youtube
5862
2. "adb shell ps -ef | grep PACKAGE_NAME"
The second way is to use the "ps" command to find the PID of a particular package. 5862
is the PID of Youtube.
$ adb shell ps -ef | grep com.google.android.youtube
u0_a121 5862 291 18 15:03:08 ? 00:00:05 com.google.android.youtube
3. Installed packages list
The following command will output a list of all packages installed on the device.
$ adb shell pidof com.google.android.youtube
package:com.google.android.networkstack.tethering
package:com.android.cts.priv.ctsshim
package:com.google.android.youtube
package:com.android.internal.display.cutout.emulation.corner
package:com.google.android.ext.services
package:com.android.internal.display.cutout.emulation.double
package:com.android.providers.telephony
package:com.android.dynsystem
package:com.android.theme.icon.pebble
...
4. 현재 실행 중인 Activity 이름
You can check the name of the Activity that is running with the following command. When the Activity is running, the following log is printed in the events log.
$ adb shell logcat -b events | grep wm_on_re
07-11 14:44:34.246 923 923 I wm_on_resume_called: [152199755,com.android.settings.FallbackHome,RESUME_ACTIVITY]
07-11 14:44:37.114 1045 1045 I wm_on_resume_called: [218164884,com.google.android.apps.nexuslauncher.NexusLauncherActivity,RESUME_ACTIVITY]
07-11 14:49:55.441 4941 4941 I wm_on_resume_called: [224219331,com.google.android.apps.youtube.app.WatchWhileActivity,RESUME_ACTIVITY]
Related Posts
- How to download and build Android 13, AOSP
- Notification permission request, pop up notification in Android 13
- Resolve `Access blocked: ComponentInfo` error on Android 13
- Fix error "android gradle plugin requires java 11 to run. you are currently using java 1.8."
- Android - Vibration, Vibrator, VibrationEffect example
- How to get phone number in Android
- How to create Bugreports and Logcat with ADB in Android
- Clear application user data with ADB in Android
- How to disable/enable apps with ADB in Android
- How to find PID of a package with adb in Android
- How to grant/revoke permissions with adb in Android
- How to install an apk(app) with adb in Android
- How to kill a process/package from ADB in Android
- How to transfer files using adb push/pull command in Android
- How to capture the screen from adb in Android
- How to uninstall/install system apps from adb in Android
- How to change Settings values from adb in Android
- How to Factory reset with ADB in Android
- How to get logcat from ADB command in Android
- How to capture Heap Dump from app with ADB in Android
- How to force stop an app with adb in Android
- How to start/stop a service from adb in Android
- How to send/broadcast an intent from adb command in Android
- How to start an activity from adb in Android
- How to generate input from adb in Android
- How to check SQLite DB table in Android Studio
- How to get memory info and thread list from adb in Android
- Android - Uri, Scheme and SSP(Scheme Specific Part)
- How to parse a xml file with XmlResourceParser in Android
- Android - Signing an apk with Platfom key
- How to fix "Cleartext HTTP ... not permitted" for Android development
- How to fix "kvm permission denied" for Android Emulator
- Using ADB over Wifi for Android development