Abdulrehman
Abdulrehman

Reputation: 445

How to find out activity names in a package? android. ADB shell

I can get a list of all the packages installed on my android, but to open an application I need the activity name and the package name. Is there a way to list all the activities in a package through adb shell. The android manifest file pulled from the phone doesn't help as it is the binary version of the file, therefore containing no meaningful information. And LAUNCHER 1, or main activity works for a lot of apps but not all. Therefore, I do need to find out the exact name of activities within an application.

Thanks.

Upvotes: 37

Views: 83243

Answers (7)

tejaswini teju
tejaswini teju

Reputation: 1212

Here is how:

adb shell dumpsys package | grep -i "package.name" | grep Activity

This will give all the activities in the given android package.

For Windows

adb shell dumpsys package | findstr "package.name" | findstr "Activity"

Upvotes: 63

rejdrouin
rejdrouin

Reputation: 89

To bring the question further : Is there a way to list the Package/Activity involved while doing an operation on the device ?

For example : Open Settings > Mobile Networks > Toggle VoLTE switch

I tried "logcat -c" / "logcat -d" and that doesn't do it.

Upvotes: -1

rejdrouin
rejdrouin

Reputation: 89

This discussion took me to the solution I needed. Thanks to everyone

adb shell "dumpsys package "com.android.settings" | grep -i activity | grep -i mobile | awk '{print $2}' | sort | uniq"

com.android.settings/.Settings$MobileDataUsageListActivity com.android.settings/.Settings$MobileNetworkActivity com.android.settings/.Settings$MobileNetworkListActivity

Upvotes: 0

user1874594
user1874594

Reputation: 2483

Package name itself can help filter & I do that to grab userid all the time. Wonder why no one uses it for activity. So here goes
Give me all the packages activities followed by specific filter e.g. filter 5b2a894 for package com.whatsapp . Change that name as needed.

Without collapsing

 adb shell  dumpsys package com.whatsapp | grep -i  activity

Collapse further
collapse this further to exclude filter 5b2a894 type components , remove duplicates and stack them up nicely

 adb shell  dumpsys package com.whatsapp | grep -i  activity | awk 'NF{NF-=1};1' |  sort |  uniq

Output - Without collapsing

Activity Resolver Table:
            2a9801d com.whatsapp/.accountsync.CallContactLandingActivity filter 94597dd
            72cf777 com.whatsapp/.identity.IdentityVerificationActivity filter 8aa4179
            bfefa14 com.whatsapp/.accountsync.ProfileActivity filter c096fb4
            2a9801d com.whatsapp/.accountsync.CallContactLandingActivity filter 94597dd
            7ebef6a com.whatsapp/.VoiceMessagingActivity filter 2e8e40
            7ebef6a com.whatsapp/.VoiceMessagingActivity filter 2e8e40
            bfd6630 com.whatsapp/.HomeActivity filter 885a8e6
            bfd6630 com.whatsapp/.HomeActivity filter 885a8e6
            bfefa14 com.whatsapp/.accountsync.ProfileActivity filter c096fb4
            2a9801d com.whatsapp/.accountsync.CallContactLandingActivity filter 94597dd
            2a9801d com.whatsapp/.accountsync.CallContactLandingActivity filter 94597dd
            7ebef6a com.whatsapp/.VoiceMessagingActivity filter 2e8e40
            7ebef6a com.whatsapp/.VoiceMessagingActivity filter 2e8e40
            bfd6630 com.whatsapp/.HomeActivity filter 885a8e6
            bfd6630 com.whatsapp/.HomeActivity filter 885a8e6
            72cf777 com.whatsapp/.identity.IdentityVerificationActivity filter 8aa4179
            63a60ae com.whatsapp/.payments.receiver.IndiaUpiPayIntentReceiverActivity filter e250cc6
            e5aadb3 com.whatsapp/.AcceptInviteLinkActivityDeepLink filter f736d72
            e5aadb3 com.whatsapp/.AcceptInviteLinkActivityDeepLink filter f736d72
            bfefa14 com.whatsapp/.accountsync.ProfileActivity filter c096fb4
            2a9801d com.whatsapp/.accountsync.CallContactLandingActivity filter 94597dd
            bfd6630 com.whatsapp/.HomeActivity filter 2432e27
            bfd6630 com.whatsapp/.HomeActivity filter 7d4b8d4
            bfd6630 com.whatsapp/.HomeActivity filter ddb7a7d
            dec987 com.whatsapp/.stickers.AddThirdPartyStickerPackActivity filter d06eebe
            dc42a01 com.whatsapp/.accountsync.LoginActivity filter 6cef487
            e73f6e8 com.whatsapp/.migration.export.ui.ExportMigrationActivity filter 657ed7f
            c62872c com.whatsapp/.settings.SettingsDataUsageActivity filter 6f2ee9e
            1af6ddf com.whatsapp/.authentication.AppAuthenticationActivity filter da5bb1f
            24d752a com.whatsapp/.camera.CameraActivity filter 7aa85c3
            bfefa14 com.whatsapp/.accountsync.ProfileActivity filter c096fb4
            2a9801d com.whatsapp/.accountsync.CallContactLandingActivity filter 94597dd
            7ebef6a com.whatsapp/.VoiceMessagingActivity filter 2e8e40
            bfd6630 com.whatsapp/.HomeActivity filter 885a8e6
            72cf777 com.whatsapp/.identity.IdentityVerificationActivity filter 8aa4179

Output colapsed

1af6ddf com.whatsapp/.authentication.AppAuthenticationActivity filter
24d752a com.whatsapp/.camera.CameraActivity filter
2a9801d com.whatsapp/.accountsync.CallContactLandingActivity filter
63a60ae com.whatsapp/.payments.receiver.IndiaUpiPayIntentReceiverActivity filter
72cf777 com.whatsapp/.identity.IdentityVerificationActivity filter
7ebef6a com.whatsapp/.VoiceMessagingActivity filter
Activity Resolver
bfd6630 com.whatsapp/.HomeActivity filter
bfefa14 com.whatsapp/.accountsync.ProfileActivity filter
c62872c com.whatsapp/.settings.SettingsDataUsageActivity filter
dc42a01 com.whatsapp/.accountsync.LoginActivity filter
dec987 com.whatsapp/.stickers.AddThirdPartyStickerPackActivity filter
e5aadb3 com.whatsapp/.AcceptInviteLinkActivityDeepLink filter
e73f6e8 com.whatsapp/.migration.export.ui.ExportMigrationActivity filter

Upvotes: 4

Suresh Kamrushi
Suresh Kamrushi

Reputation: 16086

This what working for me:

adb shell "dumpsys package | grep -i 'com.android.calendar' | grep 'Activity'"

I am using windows 10.

It will gives like below:

        5697056 com.android.calendar/.event.EditEventActivity
        e7285bc com.android.calendar/.homepage.AllInOneActivity
        5697056 com.android.calendar/.event.EditEventActivity
        9a9edbd com.android.calendar/.event.EventInfoActivity
        5697056 com.android.calendar/.event.EditEventActivity
        5697056 com.android.calendar/.event.EditEventActivity
        9a9edbd com.android.calendar/.event.EventInfoActivity
        e7285bc com.android.calendar/.homepage.AllInOneActivity
        a148bb4 com.android.calendar/com.miui.calendar.event.travel.EmptyTravelActivity
        e8883dd com.android.calendar/com.miui.calendar.web.WebViewActivity
        26664e6 com.android.calendar/com.miui.calendar.event.loan.LoanDetailActivity
        2c883c5 com.android.calendar/com.miui.calendar.holiday.HolidayDetailActivity
        304220e com.android.calendar/.agenda.AgendaActivity
        31751c3 com.android.calendar/com.miui.calendar.test.ModuleTestActivity
        408a44b com.android.calendar/com.miui.calendar.event.travel.FlightDetailActivity
        5e67a3c com.android.calendar/com.miui.calendar.detail.CardDetailActivity
        6befe28 com.android.calendar/com.miui.calendar.event.travel.TrainDetailActivity
        6e4511a com.android.calendar/com.miui.calendar.insertevent.InsertEventActivity
        83b3a27 com.android.calendar/com.miui.calendar.event.movie.MovieDetailActivity
        879f009 com.android.calendar/.selectcalendars.SelectVisibleCalendarsActivity
        ba96a40 com.android.calendar/com.miui.calendar.event.travel.FlightCheckInActivity
        bb29741 com.android.calendar/com.miui.calendar.event.credit.CreditDetailActivity
        ca3e972 com.android.calendar/com.miui.calendar.event.electricity.ElectricityBillDetailActivity
        e19d4d4 com.android.calendar/com.miui.calendar.event.hotel.HotelDetailActivity
        fd0667d com.android.calendar/com.miui.calendar.event.gas.GasBillDetailActivity
        ff6f42f com.android.calendar/com.miui.calendar.huangli.HuangLiDetailActivity
        e7285bc com.android.calendar/.homepage.AllInOneActivity
        134bba0 com.android.calendar/.settings.CalendarSettingsActivity
        e7285bc com.android.calendar/.homepage.AllInOneActivity
        9a9edbd com.android.calendar/.event.EventInfoActivity
        de026b2 com.android.calendar/com.miui.calendar.detail.GlobalHoroscopeDetailActivity
        e7285bc com.android.calendar/.homepage.AllInOneActivity
        304220e com.android.calendar/.agenda.AgendaActivity
        e7285bc com.android.calendar/.homepage.AllInOneActivity
        5697056 com.android.calendar/.event.EditEventActivity (2 filters)
        9a9edbd com.android.calendar/.event.EventInfoActivity
        e7285bc com.android.calendar/.homepage.AllInOneActivity
        5697056 com.android.calendar/.event.EditEventActivity (2 filters)

Upvotes: 1

Computer's Guy
Computer's Guy

Reputation: 5363

Expanding on tejaswini teju answer which didn't work because the grep command specified couldn't find anything.

This worked for me: adb shell dumpsys package | grep $packagename | grep Activity

Where packagename can be a part of the package name, such as com.whatsapp or whatsapp

It may print duplicate results.

Upvotes: 9

Forivin
Forivin

Reputation: 15508

To expand on tejaswini teju's answer, if you want to get all activities of a package and not just those containing the string "Activity", you'll have to do:

adb shell dumpsys package | grep -Eo "^[[:space:]]+[0-9a-f]+[[:space:]]+com.whatsapp/[^[:space:]]+" | grep -oE "[^[:space:]]+$"

replacing com.whatsapp with your package name.

Upvotes: 25

Related Questions