gpt4 book ai didi

Android 从对话框启动浏览器

转载 作者:搜寻专家 更新时间:2023-11-01 09:14:26 25 4
gpt4 key购买 nike

我有一个显示逐项叠加的 map View ,每个 onTap 事件都显示一个对话框,其中包含有关旅行社的信息和三个按钮,其中一个按钮应该在浏览器中打开代理网站,但是当我单击我得到的按钮:没有找到处理 Intent 的 Activity 。

这是我的代码:

protected boolean onTap(int i){
float[] results = new float[1];
Location.distanceBetween(decdegrees(appState.getMyLocation().getLatitudeE6()), decdegrees(appState.getMyLocation().getLongitudeE6()), decdegrees(points.get(i).getPoint().getLatitudeE6()), decdegrees(points.get(i).getPoint().getLongitudeE6()), results);
float distance = results[0]/1000;
DecimalFormat maxDigitsFormatter = new DecimalFormat("#.#");
String infos=points.get(i).getSnippet() + "#" + String.valueOf(maxDigitsFormatter.format(distance));
final String [] AInfos = infos.split("#");

final Dialog ADialog = new Dialog(c);
ADialog.setContentView(R.layout.travelagency);

TextView txtAgence = (TextView)ADialog.findViewById(R.id.txtAgence);
TextView txtAddress = (TextView)ADialog.findViewById(R.id.txtAddress);
TextView txtDistance = (TextView)ADialog.findViewById(R.id.txtDistance);
TextView txtFax = (TextView)ADialog.findViewById(R.id.txtFax);
Button btnCall = (Button)ADialog.findViewById(R.id.btnCall);
Button btnWebSite = (Button)ADialog.findViewById(R.id.btnWebSite);
Button btnCancel = (Button)ADialog.findViewById(R.id.btnCancel);

ADialog.setTitle(AInfos[0]);
btnCall.setText("Appeler : " + AInfos[2]);
txtAgence.setText(AInfos[1]);
txtDistance.setText("Approximativement à : " +AInfos[6] + " Km");
txtAddress.setText("Adresse : " + AInfos[3]);
txtFax.setText("Fax : " + AInfos[4]);
ADialog.show();

btnCancel.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
ADialog.dismiss();
}
});

btnWebSite.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Intent.ACTION_VIEW,Uri.parse(AInfos[5]));
v.getContext().startActivity(myIntent);
}
});

return (true);
}

我找到了例子 herehere但突然对我不起作用..

谢谢

最佳答案

这将创建在默认浏览器中打开网页的正确 Intent :

Uri url = Uri.parse("http://www.someUrl.com");
Intent intent = new Intent(Intent.ACTION_VIEW, url);
startActivity(intent);

关于Android 从对话框启动浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5754632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com