2013-10-11 76 views

回答

0

請看看here。這可能會幫助你獲得一些想法。

0

普通用戶下載應用程序有兩種最常見的方式。

「com.android.vending」是谷歌Play商店,

「com.amazon.venezia」是亞馬遜的Appstore,

「空」,當它被側載(未知源)

要檢查此使用下面的代碼:

final PackageManager packageManager = getPackageManager(); 

try { 
    final ApplicationInfo applicationInfo = packageManager.getApplicationInfo(getPackageName(), 0); 
    if ("com.android.vending".equals(packageManager.getInstallerPackageName(applicationInfo.packageName))) { 
     // App was installed by Play Store 
    } else if ("com.amazon.venezia".equals(packageManager.getInstallerPackageName(applicationInfo.packageName))) { 
     // App was installed by Amazon Appstore 
    } else { 
     // App was installed from somewhere else 
    } 
} catch (final NameNotFoundException e) { 
    e.printStackTrace(); 
}