1.
try{
Uri uri = Uri.parse("market://details?id="+getPackageName());
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}catch(ActivityNotFoundException e){
Toast.makeText(context, "Couldn't launch the market !", Toast.LENGTH_SHORT).show();
}
如果还要加上评论的内容的话:
intent.setAction(Intent.ACTION_SEND); iIntent.setType("text/*"); intent.putExtra(Intent.EXTRA_TEXT, "内容”);
2.
public void test(View v) {
// 判断360市场是否存在
if (isAvilible(My.this, "com.qihoo.appstore")) {
// 市场存在
Intent intent = new Intent(Intent.ACTION_VIEW);
// 跳转到360市场评分
ComponentName cn = new ComponentName("com.qihoo.appstore",
"com.qihoo.appstore.activities.SearchDistributionActivity");
intent.setComponent(cn);
intent.setData(Uri
.parse("market://details?id=com.paopaobeauty.meinv"));
startActivity(intent);
} else {
// 市场不存在
Toast.makeText(getApplicationContext(), "请下载360手机助手", 0).show();
}
}
//判断市场是否存在的方法
public static boolean isAvilible(Context context, String packageName){
final PackageManager packageManager = context.getPackageManager();//获取packagemanager
List< PackageInfo> pinfo = packageManager.getInstalledPackages(0);//获取所有已安装程序的包信息
List<String> pName = new ArrayList<String>();//用于存储所有已安装程序的包名
//从pinfo中将包名字逐一取出,压入pName list中
if(pinfo != null){
for(int i = 0; i < pinfo.size(); i++){
String pn = pinfo.get(i).packageName;
pName.add(pn);
}
}
return pName.contains(packageName);//判断pName中是否有目标程序的包名,有TRUE,没有FALSE
}
//判断360市场是否存在
if (GetUri.isAvilible(AppsActivity.this, "com.qihoo.appstore")) {
//市场存在
}else{
//市场不存在
}