admin管理员组文章数量:1662623
Android进入商店并跳转到指定应用
效果图
对话框
// 提示好评
Dialog dialog = new AlertDialog.Builder(this)
.setTitle("评价")
.setMessage("大爷,给个好评吧~~")
.setPositiveButton("准奏", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
openApplicationMarket("com.bitmain.btccom");
}
})
.setNegativeButton("滚粗", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "关闭", Toast.LENGTH_SHORT).show();
}
})
.setNeutralButton("别再烦我", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO 设置下次不再提醒
Toast.makeText(getApplicationContext(), "不再提醒", Toast.LENGTH_SHORT).show();
}
})
.create();
dialog.show();
进入商店
/**
* 通过包名 在应用商店打开应用
*
* @param packageName 包名
*/
private void openApplicationMarket(String packageName) {
try {
String str = "market://details?id=" + packageName;
Intent localIntent = new Intent(Intent.ACTION_VIEW);
localIntent.setData(Uri.parse(str));
startActivity(localIntent);
} catch (Exception e) {
// 打开应用商店失败 可能是没有手机没有安装应用市场
e.printStackTrace();
Toast.makeText(getApplicationContext(), "打开应用商店失败", Toast.LENGTH_SHORT).show();
// 调用系统浏览器进入商城
String url = "http://app.mi/detail/163525?ref=search";
openLinkBySystem(url);
}
}
/**
* 调用系统浏览器打开网页
*
* @param url 地址
*/
private void openLinkBySystem(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}
其他
打开应用商店
try {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_APP_MARKET);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
版权声明:本文标题:Android进入商店并跳转到指定应用 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1729958160a1217406.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论