there is, say, google.com. How to insert text from getName () and click the search button .. here is the GeoPoint code

package com.example.app; import android.location.Location; import java.util.Collection; public class GeoPoint { public final double lat; public final double lon; public String name; public GeoPoint(double lat, double lon, String name) { this.lat = lat; this.lon = lon; this.name = name; } public String getName(){ return name; } public GeoPoint(Location location) { this.lat = location.getLatitude(); this.lon = location.getLongitude(); } public static GeoPoint getNearestLocation(GeoPoint current, Collection<GeoPoint> locations) { GeoPoint res = null; float lastDisance = Float.MAX_VALUE; float locDistance[] = new float[1]; for (GeoPoint loc: locations) { Location.distanceBetween(current.lat, current.lon, loc.lat, loc.lon, locDistance); if (res == null || locDistance[0] < lastDisance) { res = loc; lastDisance = locDistance[0]; } } return res; } } 
  • Please explain how the name that you want to insert is connected with the rest of the code. - Kota1921
  • just getName () in the code .. help, how to insert something - DenShDen
  • one
    Do you, by chance, need geocoding ? - eigenein

2 answers 2

The easiest way to see what kind of request forms the site when you click on the button, after filling out the fields. Then try to repeat a similar request but with your own data from the application, parse the results. + It’s not quite clear if you have access to the site \ if the site has api. + Under Js there is a SlimerJS, here’s an article . In it, about what you need, but alas, for Android, I do not know analogs.

    Open the page at https://www.google.ru/#newwindow=1&q=ВАШ ТЕКСТ ИЗ getName() and continue to do with it what you need. This can be done in different ways, for example, the library https://github.com/square/okhttp