由于三星没有实现 PackageManager.getInstallerPackageName(),它仍然返回 null。所以使用 PackageManager.getInstalledPackages() 来获取所有的包并搜索 samsungapp 包名“com.sec.android.app.samsungapps”。
商店:
null - developer
com.android.vending - google play
com.amazon.venezia - amazon app
com.sec.android.app.samsungapps - samsung app store
代码:
// lets start with google play store link
String link = "https://play.google.com/store/apps/details?id=com.hellothupten.capital2countryquiz";
//find out the installer for your app package name.
String installer = getPackageManager().getInstallerPackageName(
"com.hellothupten.capital2countryquiz");
if (installer == null) {
List<PackageInfo> installedPackages = getPackageManager()
.getInstalledPackages(PackageManager.GET_ACTIVITIES);
for (PackageInfo p : installedPackages) {
if (p.packageName.contains("samsungapps")) {
// change to samsung app store link
link = "http://apps.samsung.com/mars/topApps/topAppsDetail.as?productId=000000840239";
break;
}
}
} else if (installer.contains("amazon")) {
// change to amazon app store link
link = "amzn://apps/android?p=com.hellothupten.capital2countryquiz";
} else if (installer.contains("samsung")) {
// change to samsung app store link. This does not
// exist..but who knows samsung may implement
// getInstallerPackageName in future, I assume it will
// contain a word samsung in its package name.
link = "http://apps.samsung.com/mars/topApps/topAppsDetail.as?productId=000000840239";
}
使用链接变量作为商店链接。
更新:
samsungapps://ProductDetail/com.sec.chaton
三星:http: //developer.samsung.com/android/technical-docs/Samsung-Apps-Deeplink-Guide