3

I have 0 experience in Android, so this basic question.

I am not a programmer, so i want something like shell commands than code.

In my phone i have set of applications installed. I can know how to find list of packages of the application by

adb shell pm list packages

From the list of packages that displayed with above command, Once i know my package name(say xyz package) what shell command i have to use to list all the activities under that package(xyz package).

Is there a way to know activity names from the apk file? I can get the apk file name from the package my using

 adb shell pm list packages -f "my package name"

So can you please let me know the shell command to list of activity names from the apk file.

Uday
  • 1,433
  • 10
  • 36
  • 57

3 Answers3

3

So can you please let me know the shell command to list of activity names from the apk file.

Assuming you have access to the APK file, you can use aapt (which comes with the Android SDK build tools) to read the contents of the packaged manifest:

aapt l -a filename.apk

The output also includes a (potentially large) list of all resources and identifiers. The manifest-specific output should be at the bottom.

If you're only interested in the manifest and don't care about the resources and stuff, you could leverage sed to skip all other content:

aapt l -a filename.apk | sed -n -e '/manifest/,$p'

Sample output:

Android manifest:
N: android=http://schemas.android.com/apk/res/android
  E: manifest (line=2)
    A: android:versionCode(0x0101021b)=(type 0x10)0x2
    A: android:versionName(0x0101021c)="1.1" (Raw: "1.1")
    A: package="com.example.packagename" (Raw: "com.example.packagename")
    E: uses-sdk (line=4)
      A: android:minSdkVersion(0x0101020c)=(type 0x10)0x7
      A: android:targetSdkVersion(0x01010270)=(type 0x10)0xf
    E: uses-permission (line=6)
      A: android:name(0x01010003)="android.permission.WRITE_EXTERNAL_STORAGE" (Raw: "android.permission.WRITE_EXTERNAL_STORAGE")
    E: uses-permission (line=7)
      A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
    E: uses-permission (line=8)
      A: android:name(0x01010003)="android.permission.ACCESS_NETWORK_STATE" (Raw: "android.permission.ACCESS_NETWORK_STATE")
    E: uses-permission (line=9)
      A: android:name(0x01010003)="android.permission.CAMERA" (Raw: "android.permission.CAMERA")
    E: uses-feature (line=11)
      A: android:name(0x01010003)="android.hardware.camera" (Raw: "android.hardware.camera")
    E: application (line=13)
      A: android:theme(0x01010000)=@0x1030007
      A: android:label(0x01010001)=@0x7f0a001e
      A: android:icon(0x01010002)=@0x7f020077
      A: android:name(0x01010003)=".Application" (Raw: ".Application")
      E: activity (line=14)
        A: android:label(0x01010001)=@0x7f0a001e
        A: android:name(0x01010003)=".Activity1" (Raw: ".Activity1")
        A: android:screenOrientation(0x0101001e)=(type 0x10)0x1
        E: intent-filter (line=15)
          E: action (line=16)
            A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
          E: category (line=18)
            A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
      E: activity (line=21)
        A: android:name(0x01010003)=".Activity2" (Raw: ".Activity2")
        A: android:screenOrientation(0x0101001e)=(type 0x10)0x1
        A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x2
      E: activity (line=22)
        A: android:name(0x01010003)=".Activity3" (Raw: ".Activity3")
        A: android:screenOrientation(0x0101001e)=(type 0x10)0x1
      E: activity (line=23)
        A: android:name(0x01010003)=".Activity4" (Raw: ".Activity4")
        A: android:screenOrientation(0x0101001e)=(type 0x10)0x1
      E: activity (line=24)
        A: android:name(0x01010003)=".Activity5" (Raw: ".Activity5")
        A: android:screenOrientation(0x0101001e)=(type 0x10)0x1
        A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x2
      E: activity (line=25)
        A: android:name(0x01010003)=".Activity6" (Raw: ".Activity6")
        A: android:screenOrientation(0x0101001e)=(type 0x10)0x1
      E: activity (line=26)
        A: android:name(0x01010003)=".Activity7" (Raw: ".Activity7")
        A: android:screenOrientation(0x0101001e)=(type 0x10)0x0

You can probably filter further to get to just the activity names, but I'll leave that up yourself to figure out. :)

References:

Community
  • 1
  • 1
MH.
  • 45,303
  • 10
  • 103
  • 116
2

adb shell dumpsys package <packageName> will list all activity of a package with all activity names and corresponding intents

Gowtham
  • 177
  • 1
  • 7
1

you get it like this:

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

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)
Suresh Kamrushi
  • 15,627
  • 13
  • 75
  • 90