3

AndroidのPackageManagerクラスには、currentToCanonicalPackageNames()メソッドとcanonicalToCurrentPackageNames()メソッドがあります。正規のパッケージ名は正確には何ですか?それはどこで使用されますか(その目的は何ですか)?現在のパッケージ名と異なるのはいつですか?

たとえば、私のNexus Sでは、ブラウザアプリの現在のパッケージ名は「com.google.android.browser」であり、その正規名は同じ「com.google.android.browser」です。私がチェックした他のいくつかのアプリケーションについては、同じ現在の正規のパッケージ名も取得します。developer.android.comもソースコードも、正規のパッケージ名が正確に何であるかについての説明を私に与えません。これが私が上で求めていることをよりよく理解するのに役立つことを願っています。

4

1 に答える 1

3

開発者向けドキュメントは次のとおりです。

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.

理解を深めるために、ソースのこのリンクを確認して ください。

そして、この StackOverflow の質問を参照してください: How do i get canonical names of packages of deafult apps in Android

于 2013-01-13T17:44:45.313 に答える