我需要检查是否在Android Market安装这样
I need to check if the Android Market is installed like this
/*
* Test for existence of Android Market
*/
boolean androidMarketExists = false;
try{
ApplicationInfo info = getPackageManager()
.getApplicationInfo("com.google.process.gapps", 0 );
//application exists
androidMarketExists = true;
} catch( PackageManager.NameNotFoundException e ){
//application doesn't exist
androidMarketExists = false;
}
但我不知道是否com.google.process.gapps是具有安卓市场或包装不。
But I don't know if com.google.process.gapps is the package that has android market or not.
它com.android.vending(在我的Galaxy S),这里是更好的办法,找出...通过查询谁处理市场:// URI的。
It's com.android.vending (on my Galaxy S), and here's the better way to find out... by querying for who handles market:// URIs.
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://search?q=foo"));
PackageManager pm = getPackageManager();
List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
如果该列表具有至少一个条目,该市场的存在。
If the list has at least one entry, the Market's there.