Click here to Skip to main content
14,335,049 members
Rate this:
Please Sign up or sign in to vote.
I had made it an app which is for food basically what I want to do is know I want to show food stores as per user location for example

 if (userlocation == "RAJAPARK") {
            thencallThisfunction();
        }

 else (userlocation == "XYZ") {
Toast.makeText(getActivity(), "There is no food store around you",

}


but i am not able to match a street name with my variable and i am not getting any proper guide for doing this so plz help me

What I have tried:

I tried to get user street name and matching with my variables but it does not work
by following this link - http://javapapers.com/android/android-get-address-with-street-name-city-for-location-with-geocoding/
Posted
Updated 13-Sep-16 0:17am
Rate this:
Please Sign up or sign in to vote.

Solution 1

   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 2

Quote:
I tried to get user street name and matching with my variables but it does not work

Using street name just feel like complicating things.
I would just use GPS user coordinates and calc distances with food shops and return only closest shops.

Distance calculation between 2 GPS coordinates is done with
Great-circle distance - Wikipedia, the free encyclopedia[^]

In order to reduce the number of distance calculations, you need a clever way of storing shops.
- The most simple way is to have all shops in a flat list, downside, you have to calculate distance to every shop every times.
- You can be more efficient by dividing the map in squares and note the square for each shop. Once you know which square you are, you just have to check shops in actual square and squares nearby.
Hilbert curve - Wikipedia, the free encyclopedia[^]
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100