//获取手机品牌
if (android.os.Build.BRAND.toString().contains("Xiaomi")) {
PackageInfo pack=null;
PackageInfo pack1=null;
PackageInfo pack2=null;
Uri uri = Uri.parse("market://details?id=" + "com.zzkrst.mss.courier");
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
try {
//百度应用商店
pack=getPackageManager().getPackageInfo("com.baidu.appsearch", 0);
packlist.add(pack);
if (packlist!=null) {
goToMarket.setPackage("com.baidu.appsearch");//其中的com.lkk.travel是自己app的包名
context.startActivity(goToMarket);
}
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
try {
//360应用商店
pack1=getPackageManager().getPackageInfo("com.qihoo.appstore", 0);
packlist.add(pack1);
if (packlist!=null) {
goToMarket.setPackage("com.qihoo.appstore");
context.startActivity(goToMarket);
}
} catch (NameNotFoundException e1) {
// TODO Auto-generated catch block
try {
//腾讯应用宝
pack2=getPackageManager().getPackageInfo("com.tencent.android.qqdownloader", 0);
packlist.add(pack2);
if (packlist!=null) {
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
goToMarket.setPackage("com.tencent.android.qqdownloader");
context.startActivity(goToMarket);
}
} catch (NameNotFoundException e2) {
// TODO Auto-generated catch block
toast.makeText(NewMainActivity.this, "请至少安装百度手机助手或腾讯应用宝或360应用商店其中一个进行更新APP", 0).show();
e2.printStackTrace();
try {
Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
field.setAccessible(true);
field.set(dialog, false);
} catch (Exception ex) {
ex.printStackTrace();
}
}
e1.printStackTrace();
}
e.printStackTrace();
}
}
else{
PackageInfo pack=null;
PackageInfo pack1=null;
PackageInfo pack2=null;
Intent intent = new Intent(Intent.ACTION_VIEW);
try {
pack=getPackageManager().getPackageInfo("com.baidu.appsearch", 0);
packlist.add(pack);
if (packlist!=null) {
intent.setData(Uri.parse("market://details?id="+"com.zzkrst.mss.courier"));//其中的com.lkk.travel是自己app的包名
startActivity(intent);
}
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
try {
pack1=getPackageManager().getPackageInfo("com.qihoo.appstore", 0);
packlist.add(pack1);
if (packlist!=null) {
intent.setData(Uri.parse("market://details?id="+"com.zzkrst.mss.courier"));//其中的com.lkk.travel是自己app的包名
startActivity(intent);
}
} catch (NameNotFoundException e1) {
// TODO Auto-generated catch block
try {
pack2=getPackageManager().getPackageInfo("com.tencent.android.qqdownloader", 0);
packlist.add(pack2);
if (packlist!=null) {
intent.setData(Uri.parse("market://details?id="+"com.zzkrst.mss.courier"));//其中的com.lkk.travel是自己app的包名
startActivity(intent);
}
} catch (NameNotFoundException e2) {
// TODO Auto-generated catch block
toast.makeText(NewMainActivity.this, "请至少安装百度手机助手或腾讯应用宝或360应用商店其中一个进行更新APP", 0).show();
e2.printStackTrace();
try {
Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
field.setAccessible(true);
field.set(dialog, false);
} catch (Exception ex) {
ex.printStackTrace();
}
}
e1.printStackTrace();
}
e.printStackTrace();
}
}