47

I'm creating a mobile website that will include a page from which people can download relevant apps that we recommend. I've found instructions for creating the links to launch the Market but this assumes that you are the developer of the app in question and know the exact package name.

Is there any way to get the package name, other than just contacting the developers and asking?

Also, it turns out that those instructions don't really work for creating web hyperlinks. They only give you a URI to reference in a string of Java code in another Android app. Our site is in Drupal, so Java is not going to work.

For the iPhone, I found easy instructions for getting the URL/link style I need from the iTunes store, so I'm looking for info like that.

Mario Kutlev
  • 4,897
  • 7
  • 44
  • 62
eom
  • 649
  • 2
  • 9
  • 10

12 Answers12

99

It depends where exactly you want to get the information from. You have a bunch of options:

  • If you have a copy of the .apk, it's just a case of opening it as a zip file and looking at the AndroidManifest.xml file. The top level <manifest> element will have a package attribute.
  • If you have the app installed on a device and can connect using adb, you can launch adb shell and execute pm list packages -f, which shows the package name for each installed apk.
  • If you just want to manually find a couple of package names, you can search for the app on http://www.cyrket.com/m/android/, and the package name is shown in the URL
  • You can also do it progmatically from an Android app using the PackageManager

Once you've got the package name, you simply link to market://search?q=pname:<package_name> or http://market.android.com/search?q=pname:<package_name>. Both will open the market on an Android device; the latter obviously has the potential to work on other hardware as well (it doesn't at the minute).

Chris
  • 10,337
  • 1
  • 38
  • 46
  • 27
    Another and simpler way is : go to the app page on android market (now google play), check the url. The app package is between ?id= and the & just after. – Martin Mar 27 '12 at 12:59
  • http://developer.android.com/guide/publishing/publishing.html Here you can find the formal info from google – Li3ro Jun 18 '12 at 15:16
  • adb shell pm list packages -f worked for me. When I tried to extract the .apk file, the AndroidManifest.xml was in binary. – jth_92 Jan 09 '13 at 16:36
  • I needed to run `pm` with `sh` for some reason: `sh pm list packages -f` – palswim May 16 '13 at 18:35
  • Opening the APK as a ZIP and looking at the contained AndroidManifest.xml does not work right away as the XML is in binary format. – sschuberth Jun 26 '15 at 06:58
55

Use aapt from the SDK like

aapt dump badging yourpkg.apk

This will print the package name together with other info.

the tools is located in
<sdk_home>/build-tools/android-<api_level>
or
<sdk_home>/platform-tools
or
<sdk_home>/platforms/android-<api_level>/tools

Updated according to geniusburger's comment. Thanks!

sschuberth
  • 28,386
  • 6
  • 101
  • 146
accuya
  • 1,412
  • 14
  • 14
8

The following bash script can be used to display the package and activity names in an apk, and launch the application by passing it an APK file.

apk_start.sh

package=`aapt dump badging $* | grep package | awk '{print $2}' | sed s/name=//g | sed s/\'//g`
activity=`aapt dump badging $* | grep Activity | awk '{print $2}' | sed s/name=//g | sed s/\'//g`
echo
echo package : $package
echo activity: $activity
echo
echo Launching application on device....
echo
adb shell am start -n $package/$activity

Then to launch the application in the emulator, simply supply the APK filename like so:

apk_start.sh /tmp/MyApp.apk

Of course if you just want the package and activity name of the apk to be displayed, delete the last line of the script.

You can stop an application in the same way by using this script:

apk_stop.sh

package=`aapt dump badging $* | grep package | awk '{print $2}' | sed s/name=//g | sed s/\'//g`
adb shell am force-stop $package

like so:

apk_stop.sh /tmp/MyApp.apk

Important Note: aapt can be found here:

<android_sdk_home>/build-tools/android-<ver>/aapt
Brad Parks
  • 66,836
  • 64
  • 257
  • 336
  • 1
    I love you! btw the build tool version i'm using, lists the activity with key launchable-activity so I had to modify the grep Activity to ``aapt dump badging $* | grep launchable-activity | awk '{print $2}' | sed s/name=//g | sed s/\'//g`` – Arnaldo Capo Mar 15 '17 at 19:57
  • Cool... glad it helped... and thanks for the suggestions... I haven't done Android dev in awhile, so it's good to know! – Brad Parks Mar 16 '17 at 00:47
4

The following code will list them out:

adb shell dumpsys package <packagename>
admdrew
  • 3,790
  • 4
  • 27
  • 39
Thejus Krishna
  • 1,755
  • 1
  • 19
  • 28
3

Not sure if you still need this, but in http://www.appbrain.com/ , you look up the app and the package name is in the url. For example: http://www.appbrain.com/app/fruit-ninja/com.halfbrick.fruitninja is the link for fruit ninja. Notice the bold

Anonymous
  • 31
  • 1
2

Adding to the above answers: To find the package name of installed apps on any android device: Go to Storage/Android/data/< package-name >

Kaushik
  • 6,150
  • 5
  • 39
  • 54
1

You can search the app online in the Google Play Store. When found, check the url, for example, https://play.google.com/store/apps/details?id=lutey.FTPServer&hl=en

The id parameter corresponds to the package name of the application. In the case of the url in the example, the package name is lutey.FTPServer.

R B
  • 11
  • 1
1

Here are easy way to get app's full package. we can use astro file manager app. You can get it on android market. Astro app manager show us app's full package.

B.C.Kim
  • 11
  • 1
0

This is quite a difficult situation, you can get the package name from the apk file, but i assume you want to do it automatically.

AndroLib has the package names for lots of apps but you would have to parse it as there is no API that i could find. Theres a dev section that may have some tools to help you.

Good Luck

Con
  • 368
  • 1
  • 7
  • Thanks. This problem is actually harder than I thought, because the instructions that I linked to above have their own flaw--they're for linking to the Market from an app, not from a website. They require Java, which I don't think is going to play well with Drupal, to say the least. – eom May 10 '10 at 14:52
0

Once you have the package name, as described Chris Smith's answer, you could/should use an intent url for the link. It's a special format URL that will launch the package if the user has already installed it, or open the play store at the application's page if not...

intent://#Intent;package=qualified.package.name;end

The app needs to support this, with an activity tagged as browsable, but many will.

Community
  • 1
  • 1
bbsimonbb
  • 27,056
  • 15
  • 80
  • 110
-1
  1. Go to setting app.
  2. Click Storage & USB.
  3. Click Phone Card.
  4. Click Android.
  5. Click Data.

Now you can find the package names of all the apps that are installed in your phone.

enter image description here

Siddarth Kanted
  • 5,738
  • 1
  • 29
  • 20
-2

If you want this information in your phone, then best is to use an app like 'APKit' that shows the full package name of each app in you phone. This information can then be used in your phone.