現在のアプリケーションからボタンクリックイベントでGoogleマップアプリケーションを開く方法。
8 に答える
以下の行を使用してください
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);
マップアプリケーションでリダイレクトされます。
あなたはあなたの開始点と終了点を与える意図でグーグルマップを開くことができます。
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");
インテントを使用する必要があります。
ここに実際の例があります
http://www.tutorialforandroid.com/2009/10/launching-other-application-using-code.html
ここに理論的な例があります
ここにAndroidのドキュメントがあります
http://developer.android.com/reference/android/content/Intent.html
それが役に立てば幸い!:)
これを行うには、AndroidManifes.xmlで「intent-filters」を指定します。アプリケーションからGoogleアプリケーションを起動する方法の詳細については、次のリンクを参照してください:インテントリスト:AndroidデバイスでのGoogleアプリケーションの呼び出し
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");
}
};
これは私の現在のアプリからグーグルマップを呼び出す別の方法です。
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);
}
次のようなものを使用できます。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);
これを使って。それがあなたのために働くことを願っています:
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);
}
});