1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn_search = findViewById(R.id.btn_search);
btn_search.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EditText et_location1 = findViewById(R.id.et_location1);
String str_locone = et_location1.getText().toString();
Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4192?q=" + Uri.encode(str_locone));
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
}
}); |
Partager