gpt4 book ai didi

安卓 : what is canonical package name?

转载 作者:行者123 更新时间:2023-12-04 03:58:25 27 4
gpt4 key购买 nike

Android 的 PackageManager 类具有 currentToCanonicalPackageNames() 和 canonicalToCurrentPackageNames() 方法。规范包名到底是什么?它在哪里使用(它的目的是什么)?它什么时候不同于当前的包名称?

例如,在我的 Nexus S 上,浏览器应用程序的当前包名称是“com.google.android.browser”,其规范名称是相同的“com.google.android.browser”。对于我检查过的其他一些应用程序,我也获得了相同的当前和规范包名称。 developer.android.com 和源代码都没有给我解释什么是规范包名称。希望这有助于更好地理解我上面的问题。

最佳答案

这是开发者文档:

http://developer.android.com/reference/android/content/pm/PackageManager.html

public abstract String[] currentToCanonicalPackageNames (String[] 名称)

Added in API level 8
Map from the current package names in use on the device to whatever the current canonical name of that package is.

Parameters
names Array of current names to be mapped.
Returns
Returns an array of the same size as the original, containing the canonical name for each package.

public abstract String[] canonicalToCurrentPackageNames (String[] 名称)

Added in API level 8
Map from a packages canonical name to the current name in use on the device.

Parameters
names Array of new names to be mapped.
Returns
Returns an array of the same size as the original, containing the current name for each package.

查看来源的这个链接以获得更好的理解: https://android.googlesource.com/platform/frameworks/base/+/483f3b06ea84440a082e21b68ec2c2e54046f5a6/core/java/android/app/ApplicationPackageManager.java

请引用这个 StackOverflow 问题:how do i get canonical names of packages of deafult apps in Android

关于安卓 : what is canonical package name?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14304401/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com