简体   繁体   English

查找Android应用程序的程序包名称,以使用Intent从Web启动Market应用程序

[英]Find package name for Android apps to use Intent to launch Market app from web

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. 而且,事实证明这些指令并不真正适用于创建Web超链接。 They only give you a URI to reference in a string of Java code in another Android app. 它们只为您提供一个URI,以便在另一个Android应用程序中的一串Java代码中引用。 Our site is in Drupal, so Java is not going to work. 我们的网站位于Drupal,因此Java无法运行。

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. 对于iPhone,我找到了从iTunes商店获取我需要的URL /链接样式的简单说明 ,所以我正在寻找这样的信息。

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. 如果您有.apk的副本,那么只需将其打开为zip文件并查看AndroidManifest.xml文件即可。 The top level <manifest> element will have a package attribute. 顶级<manifest>元素将具有package属性。
  • 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. 如果您在设备上安装了应用程序并且可以使用adb进行连接,则可以启动adb shell并执行pm list packages -f ,其中显示了每个已安装的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 如果您只想手动查找几个软件包名称,可以在http://www.cyrket.com/m/android/上搜索该应用程序,并在URL中显示软件包名称
  • You can also do it progmatically from an Android app using the PackageManager 您也可以使用PackageManager从Android应用程序进行预测

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> . 获得软件包名称后,只需链接到market://search?q=pname:<package_name>http://market.android.com/search?q=pname:<package_name> Both will open the market on an Android device; 两者都将在Android设备上打开市场; the latter obviously has the potential to work on other hardware as well (it doesn't at the minute). 后者显然也有可能在其他硬件上工作(它不会在那一刻)。

Use aapt from the SDK like 使用SDK中的aapt

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> <SDK_HOME> /构建工具/ android- <api_level>
or 要么
<sdk_home>/platform-tools <SDK_HOME> /平台的工具
or 要么
<sdk_home>/platforms/android-<api_level>/tools <SDK_HOME> /平台/ android- <api_level> /工具

Updated according to geniusburger 's comment. 根据geniusburger的评论更新。 Thanks! 谢谢!

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. 以下bash脚本可用于在apk中显示包和活动名称,并通过向其传递APK文件来启动应用程序。

apk_start.sh 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文件名,如下所示:

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. 当然,如果您只想显示apk的包和活动名称,请删除脚本的最后一行。

You can stop an application in the same way by using this script: 您可以使用此脚本以相同的方式停止应用程序:

apk_stop.sh 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: 重要说明 :aapt可以在这里找到:

<android_sdk_home>/build-tools/android-<ver>/aapt

以下代码将列出它们:

adb shell dumpsys package <packagename>

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. 不确定您是否仍然需要这个,但在http://www.appbrain.com/中 ,您查找应用程序并且包名称在URL中。 For example: http://www.appbrain.com/app/fruit-ninja/ com.halfbrick.fruitninja is the link for fruit ninja. 例如: http//www.appbrain.com/app/fruit-ninja/ com.halfbrick.fruitninja是水果忍者的链接。 Notice the bold 注意粗体

添加以上答案:要在任何Android设备上查找已安装应用程序的软件包名称: 转至Storage / Android / data / <package-name>

You can search the app online in the Google Play Store. 您可以在Google Play商店中在线搜索应用。 When found, check the url, for example, https://play.google.com/store/apps/details?id=lutey.FTPServer&hl=en 找到后,请检查网址,例如https://play.google.com/store/apps/details?id=lutey.FTPServer&hl=en

The id parameter corresponds to the package name of the application. id参数对应于应用程序的包名称。 In the case of the url in the example, the package name is lutey.FTPServer. 对于示例中的url,包名称为lutey.FTPServer。

Here are easy way to get app's full package. 这是获取应用程序完整包的简便方法。 we can use astro file manager app. 我们可以使用astro文件管理器应用程序。 You can get it on android market. 你可以在Android市场上获得它。 Astro app manager show us app's full package. Astro app manager向我们展示应用程序的完整软件包。

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. 这是一个相当困难的情况,您可以从apk文件中获取包名称,但我假设您想自动执行此操作。

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. AndroLib有很多应用程序的软件包名称,但你必须解析它,因为我找不到任何API。 Theres a dev section that may have some tools to help you. 这是一个开发部分,可能有一些工具可以帮助你。

Good Luck 祝好运

Once you have the package name, as described Chris Smith's answer , you could/should use an intent url for the link. 一旦你有了包名,就像Chris Smith的回答所描述的那样 ,你可以/应该使用一个意向URL作为链接。 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... 这是一个特殊的格式URL ,如果用户已安装它,将启动该软件包,或者如果不是,则在应用程序页面打开游戏商店...

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

The app needs to support this, with an activity tagged as browsable, but many will. 应用程序需要支持这一点,活动标记为可浏览,但许多人会。

  1. Go to setting app. 转到设置应用。
  2. Click Storage & USB. 单击存储和USB。
  3. Click Phone Card. 单击电话卡。
  4. Click Android. 点击Android。
  5. Click Data. 单击数据。

Now you can find the package names of all the apps that are installed in your phone. 现在,您可以找到手机中安装的所有应用的包名称。

在此输入图像描述

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. 如果您想在手机中使用此信息,那么最好使用类似“APK”的应用,该应用会显示手机中每个应用的完整包装名称。 This information can then be used in your phone. 然后可以在手机中使用此信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM