2

アイテム化されたオーバーレイを表示するマップビューがあり、各onTapイベントには、旅行代理店に関する情報と3つのボタンが表示されます。そのうちの1つは、ブラウザで旅行代理店のWebサイトを開くことになっていますが、ボタンをクリックすると、 :インテントを処理するアクティビティが見つかりません。

これが私のコードです:

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);
    }

私はここここで例を見つけましたが、突然私にはうまくいきませんでした。

ありがとう

4

2 に答える 2

3

これにより、デフォルトのブラウザでWebページを開くための適切なインテントが作成されます。

Uri url = Uri.parse("http://www.someUrl.com");
        Intent intent = new Intent(Intent.ACTION_VIEW, url);
        startActivity(intent);
于 2011-04-22T10:47:56.590 に答える
0

おそらくあなたAInfos[5]は適切なURLではありません。次のようなURLをハードコーディングして、http://www.google.com最初に機能するかどうかを確認します。また、含まれているものを印刷しAInfos[5]ます。

于 2011-04-22T10:53:15.597 に答える