Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all activities within an APK from the shell

Tags:

android

Is there a way to list all the activities of a particular .apk file from the shell? I found this post which describes how to list all the activities in an apk but it is not for the shell.

like image 776
amccormack Avatar asked Jul 01 '11 12:07

amccormack


People also ask

How do I view the contents of an APK file?

Since APK files come in compressed ZIP format, any ZIP decompression tool can open it. So, for viewing the contents of an APK file, all you have to do is rename its extension to . zip and open it. Or, you can open it directly through an open dialogue box of a zip application.

What is inside an APK?

It contains all the resources an app needs to run, including its Java code, native libraries, assets, manifest file, resource files, etc. The APK file format was created, so developers could deliver software to devices in a single compressed file. All the user-oriented programs on smart Android devices use APK files.

What are the parts of an APK?

An apk file contains all of that program's code (such as . dex files), resources, assets, certificates, and manifest file.

How do I explore APK files on my PC?

That being the case, you can open an APK file on a Windows computer by opening it in WinRAR, WinZip, or any other file archiving program (or by renaming the APK file in question to have the . zip extension instead of the . apk extension and then unzipping it using a file archiving program).


2 Answers

If you can pull out the apk file to your own machine, you can use the aapt command in the Android SDK

aapt dump xmltree <apk-file> AndroidManifest.xml 

The format is a bit perplexing at first, but all the info is there.

like image 162
Albin Avatar answered Oct 04 '22 16:10

Albin


The solution from @Albin will print all the elements in AndroidManifest.xml, we need to filter the output. Here is another solution only print activities as the question ask.

aapt list -a /path/to/the/apk | sed -n '/ activity /{:loop n;s/^.*android:name.*="\([^"]\{1,\}\)".*/\1/;T loop;p;t}' 
like image 34
alijandro Avatar answered Oct 04 '22 15:10

alijandro