2013-01-13 40 views
1

Android的PackageManager類有currentToCanonicalPackageNames()和canonicalToCurrentPackageNames()方法。什麼是規範包名?它在哪裏使用(它的目的是什麼)?它與當前包名稱有什麼不同?Android:什麼是規範包名?

例如,在我的Nexus S上,瀏覽器應用程序的當前軟件包名稱是「com.google.android.browser」,其規範名稱與「com.google.android.browser」相同。對於我檢查過的其他一些應用程序,我也會得到相同的當前和規範的軟件包名稱。 developer.android.com和源代碼都沒有給出解釋什麼是規範包名。希望這有助於更好地理解我上面提出的問題。

回答

4

這裏是顯影劑文檔:

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

公共抽象字符串[] currentToCanonicalPackageNames(字符串[]名稱)

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. 

公共抽象字符串[] canonicalToCurrentPackageNames(字符串[]名稱)

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

+0

是:)但究竟規範的包裝名稱代表什麼嗎?當前和規範軟件包名稱有什麼區別?何時/何地使用?我還沒有在developer.android.com找到答案 – alexaschka

+0

我已經用更多鏈接更新了我的答案。 –

+0

謝謝,但這些鏈接仍不能回答我的問題。 (另一個StackOverflow問題簡單地展示瞭如何獲得這些規範化的名稱,並且源代碼甚至沒有文檔,但是沒有一個告訴這些規範化名稱到底是什麼,它們的目的是什麼等)。 – alexaschka