android - 调用 onBackPressed 时如何设置链接
问题描述
我是新的 Android 开发人员,我想在调用 onBackPressed 时为我的第三个按钮设置链接。其余 2 人工作正常。但我想,当点击“更多应用”时,它会重定向到 Google Play 商店。我怎么做?请帮助我专家开发人员。
@Override
public void onBackPressed() {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setIcon(R.drawable.ic_close);
alert.setCancelable(false);
alert.setNeutralButton("More Apps", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
alert.setTitle("Listview Application");
alert.setMessage("Do you want to close?");
alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
alert.setPositiveButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
alert.show();
}
解决方案
调用此方法。
public void openMoreApps(String playStoreUrl) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(playStoreUrl));
startActivity(intent);
}
推荐阅读
- python - 如何将多个 .jpg 转换为 .mp4,每个 .jpg 都有单独的持续时间?
- c++ - VS2015下无法启动64位应用
- c++ - '打印输出' CLIPS 缺少函数声明
- recursion - Common Lisp 中的递归、推送值和斐波那契数列
- shell - 从鱼脚本执行通知发送作为cronjob
- flutter - DriverError:由于远程错误颤动,未能完成 Tap
- python - 如何删除 CSV 中的所有标点符号、特殊字符并用“数字”字符串替换数字?
- web-component - 向开槽元素添加类(?)
- python - 如何提取点击值
- java - 如何使用 RestTemplate 和 JUnit 测试 restclient?