private void goToAppMarket(){
try {
Uri uri = Uri.parse("market://details?id=" + getPackageName());
Intent hasinstalled = new Intent(Intent.ACTION_VIEW, uri);
ArrayList<Intent> targetintent = new ArrayList<Intent>();
//获取手机已安装市场
List<ResolveInfo> marketlist = getPackageManager().queryIntentActivities(hasinstalled, 0);
for (ResolveInfo info : marketlist) {
ActivityInfo actinfo = info.activityInfo;
if (filterMarket(actinfo.packageName))
continue;
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setPackage(actinfo.packageName);
targetintent.add(intent);
}
if (targetintent.size() > 0) {
Intent chooser = Intent.createChooser(targetintent.remove(0), getString(R.string.about_select_app));
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetintent.toArray(new Parcelable[]{}));
startActivity(chooser);
} else {
Toast.makeText(this, getString(R.string.myinfo_about_take_score_no_market), Toast.LENGTH_SHORT).show();
}
}catch (Throwable e){
Toast.makeText(this, getString(R.string.myinfo_about_take_score_no_market),Toast.LENGTH_SHORT).show();
}
}
/**
* 筛选市场应用,拦截非应用渠道市场
* @return true 拦截 fase 未拦截
*/
private boolean filterMarket(String packageName)
{
if(MARKET_APP_TYPE_360.equals(packageName)){//360手机助手
return false;
}else if(MARKET_APP_TYPE_WANDOUJIA.equals(packageName)){//豌豆荚
return false;
}else if(MARKET_APP_TYPE_ANDROID.equals(packageName)){//安卓市场
return false;
}else if(MARKET_APP_TYPE_BAIDU.equals(packageName)){//百度手机助手
return false;
}else if(MARKET_APP_TYPE_XIAOMI.equals(packageName)){//小米商城
return false;
}
return true;
}
try {
Uri uri = Uri.parse("market://details?id=" + getPackageName());
Intent hasinstalled = new Intent(Intent.ACTION_VIEW, uri);
ArrayList<Intent> targetintent = new ArrayList<Intent>();
//获取手机已安装市场
List<ResolveInfo> marketlist = getPackageManager().queryIntentActivities(hasinstalled, 0);
for (ResolveInfo info : marketlist) {
ActivityInfo actinfo = info.activityInfo;
if (filterMarket(actinfo.packageName))
continue;
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setPackage(actinfo.packageName);
targetintent.add(intent);
}
if (targetintent.size() > 0) {
Intent chooser = Intent.createChooser(targetintent.remove(0), getString(R.string.about_select_app));
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetintent.toArray(new Parcelable[]{}));
startActivity(chooser);
} else {
Toast.makeText(this, getString(R.string.myinfo_about_take_score_no_market), Toast.LENGTH_SHORT).show();
}
}catch (Throwable e){
Toast.makeText(this, getString(R.string.myinfo_about_take_score_no_market),Toast.LENGTH_SHORT).show();
}
}
/**
* 筛选市场应用,拦截非应用渠道市场
* @return true 拦截 fase 未拦截
*/
private boolean filterMarket(String packageName)
{
if(MARKET_APP_TYPE_360.equals(packageName)){//360手机助手
return false;
}else if(MARKET_APP_TYPE_WANDOUJIA.equals(packageName)){//豌豆荚
return false;
}else if(MARKET_APP_TYPE_ANDROID.equals(packageName)){//安卓市场
return false;
}else if(MARKET_APP_TYPE_BAIDU.equals(packageName)){//百度手机助手
return false;
}else if(MARKET_APP_TYPE_XIAOMI.equals(packageName)){//小米商城
return false;
}
return true;
}