1

現在のアプリケーションからボタンクリックイベントでGoogleマップアプリケーションを開く方法。

4

8 に答える 8

5

以下の行を使用してください

String uri = "http://maps.google.com/";
            Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
            intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
            startActivity(intent);

マップアプリケーションでリダイレクトされます。

于 2012-07-23T06:55:07.253 に答える
3

あなたはあなたの開始点と終了点を与える意図でグーグルマップを開くことができます。

Intent navigation = new Intent(Intent.ACTION_VIEW, Uri
        .parse("http://maps.google.com/maps?saddr="
                + Constants.latitude + ","
                + Constants.longitude + "&daddr="
                + latitude + "," + longitude));
startActivity(navigation);

これにより、マップアプリケーションが開きます。ブラウザまたはグーグルマップアプリケーションを意味します。グーグルマップが必要でダイアログを削除したい場合は、使用するパッケージに関するヒントをインテントに与えることができます。

startActivity()これを追加する前に:

intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
于 2012-07-23T06:58:52.873 に答える
2

インテントを使用する必要があります。

ここに実際の例があります

http://www.tutorialforandroid.com/2009/10/launching-other-application-using-code.html

ここに理論的な例があります

自分の(意図)から別のアプリケーションを開く

ここにAndroidのドキュメントがあります

http://developer.android.com/reference/android/content/Intent.html

それが役に立てば幸い!:)

于 2012-07-23T06:56:47.133 に答える
1

これを行うには、AndroidManifes.xmlで「intent-filters」を指定します。アプリケーションからGoogleアプリケーションを起動する方法の詳細については、次のリンクを参照してください:インテントリスト:AndroidデバイスでのGoogleアプリケーションの呼び出し

于 2012-07-23T06:54:46.140 に答える
1
WebView view=(WebView) findViewById(R.id.w);    
Button button=(Button) findViewById(R.id.nxt);

button.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                     view.loadUrl("http://maps.google.co.in/maps?hl=en&tab=wl");
                    }
                        };
于 2012-07-23T07:00:56.123 に答える
0

これは私の現在のアプリからグーグルマップを呼び出す別の方法です。

String SettingsPage = "com.google.android.apps.maps/com.google.android.maps.MapsActivity";

                try
                {
                Intent intent = new Intent(Intent.ACTION_MAIN);             
                intent.setComponent(ComponentName.unflattenFromString(SettingsPage));             
                intent.addCategory(Intent.CATEGORY_LAUNCHER );             
                startActivity(intent); 
                }
                catch (ActivityNotFoundException e)
                {
                 Log.e("Activity Not Found","");
                }
                catch (Exception e) {
                     Log.e("Activity Not Found",""+e);
                }
于 2012-07-24T05:36:29.740 に答える
0

次のようなものを使用できます。Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345")); startActivity(intent);

于 2012-07-23T07:07:10.957 に答える
0

これを使って。それがあなたのために働くことを願っています:

 Button showMap = (Button) findViewById(R.id.btn_showMap);
 showMap .setOnClickListener(new OnClickListener()
 {
 public void onClick(View v){
 Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:"+ latitude +","+ longitude ));
 startActivity(i);
 }
 });
于 2017-06-20T09:43:26.317 に答える