Google Places autocomplete for Android only capturing street - android

I am working with Google's autocomplete widget for Android, but for some reason it appears to only be capturing the street number and name, but no other part, of the completed address. Here is a screenshot where I entered 91 Hudson Avenue into the autocomplete box:
Here is the snippet of my Java code which obtains the place name from the widget after a place has been selected from the drop down list:
#Override
public void onPlaceSelected(Place place) {
address = place.getName().toString();
}
The value of address is always 91 Hudson Ave without a city, state, or country, despite that I chose one of the options from the drop down menu. My guess is that there is some silly configuration step which I am missing.
If you want any other information about my setup, let me know and I can edit as soon as I get a chance.

It is because of you are doing this:
address = place.getName().toString();
You should be doing this:
ddress = place.getAddress().toString();
d

Related

Android CountryCodePicker set country to null

I use the CountryCodePicker from the CountryCodePickerProject by hbb20.
I get the User's data from the DataBase, and sometimes for whatever reason the User has "" (empty string) saved as their country.
I use this Picker to edit their country, and if the User does not change his country then I get India "IN" as the selectedCCPCountry since the defaultCCPCountry automatically returns India if no country was set.
How can I set the selectedCCPCountry or some other flag to null or "" so that in this case I can know not to change the User's data?
Thanks!
So I created an issue for this on GitHub and got a quick response from the author:
It seems like your primary use case is to select country without phone
number validation, did I get that right? if so, you should try Android
Country Picker (https://github.com/hbb20/AndroidCountryPicker). It has out
of box support for non selection and much more. Please let me know if that
works for you.
Here is my response and my temporary workaround:
As I don't want to undo all the code I have already, I made a temporary workaround.
mCountryChangedByUser is false and turns true only when a country is selected inside the CountryCodePicker.
mCountryCCP.setOnCountryChangeListener(new CountryCodePicker.OnCountryChangeListener() {
#Override
public void onCountrySelected() {
mCountryChangedByUser = true;
mCountryTextTV.setText(mCountryCCP.getSelectedCountryName());
mUser.setCountry(mCountryCCP.getSelectedCountryNameCode());
}
});
If the user did not change his country then just return the original country in my saveUser() function.
if (mCountryChangedByUser) {
userUpdate.setCountry(mCountryCCP.getSelectedCountryNameCode() );
} else {
userUpdate.setCountry(mUser.getCountry());
}
Maybe next time I'll use the AndroidCountryPicker.
Thanks!

How to show marker on that lat/long when appending lat/long in Here We Go Url and How can i get Phone number from place api

I used Reverse Geocoding in my code using TRACK_POSITION where i need to pass
bearing .
ResultListener<Location> listener = new ReverseGeocodeListener();
ReverseGeocodeRequest2 request = new ReverseGeocodeRequest2(geoCoord, null, RETRIEVE_ADDRESSES, bearing);
if (request.execute(listener) != ErrorCode.NONE)
{
// Handle request error ...
}
It takes float value and i am confused what should be the value of bearing. i hardcoded some vale which still gives me response and i am getting street name as result/ response of ReverseGeocoding with lat/long/alt, now here comes the problem i want to get the link of Here We Go website of the particular lat/long.
Case 1: (What i was trying to do)
So i Stored a string value of Here We Go url and i wanted to append lat/long to the url i was successful to do so but the link i am getting is showing me just the area not the marker on the lat/long. how can i achieve the marker on that lat/long.
Case 2: Is there anything we can do programatically to enter lat/long inside the search textbox of Here We Go(this thing shows marker on the position) and get the url of that search and store it in the string ?
I am also using Place Api for getting nearby place depending on categories, but i am not getting phone number value in response with other values.As i search for it on the developer website it says we need special access but i have Here Premium SDK so can you guys help with this i tried contacting Here but no response.
Any help would be Appreciated. Thanks in Advance.
We hope both case 1 & 2 of your question drills down to how to append the search term (in your case lat,long) to the here we go map to get a marker on the map. If this is right, then all you need is to call the here url with the search lat,long like this: wego.here.com/search/51.52395,-0.15818

how to show nearby object as per user location?

I want to show food stores as per user street for example if user is in street name called ABC then map will show only those marker which is around in street ABC
if (userlocation == "isInStreet1") {
thencallThisfunction();
}
else if (userlocation == "isInStreet2") {
Toast.makeText(getActivity(), "There is no food store around you", }
but i don't have any idea how to do this ... i can able to get current location of the user but i am not getting how to show nearby object as per their location
Have you considered using the GPS to get your coordinates and then using them to get the address info including the street name. Once you have that infomration you can compare the strings to the list of street names you have.
See the accepted solution from this question: Android - How to get street name from coordinates?
It seems like you'd want to use the Google Places API.
In particular the Places 'search' function which allows you to find places near a specified Latitude/Longitude

Android issue with Skobbler SDK for offline geocoding

I implemented Skobbler SDK in my app to navigate offline maps. I have an issue while trying to get coordinates from an address when user is offline. Even if I have installed the package relative to the city in which I am trying to navigate, when I start multi-step search it returns empty results without the possibility to understand what I am doing wrong because there is no way to manage eventual error messages. Here is my code as reported in Skobbler docs:
private void searchAtCurrentLevel(long parentId, SKSearchManager.SKListLevel level) {
// get a search manager object
SKSearchManager mgr = new SKSearchManager(this);
// get a multi-step search object
SKMultiStepSearchSettings searchSettings = new SKMultiStepSearchSettings();
// set the offline package in which to search
searchSettings.setOfflinePackageCode(code);
// set list level of the search
searchSettings.setListLevel(level);
// set maximum number of results to be received
searchSettings.setMaxSearchResultsNumber(20);
// set the id of the parent in which to search
searchSettings.setParentIndex(parentId);
// set a filter for the results
searchSettings.setSearchTerm("");
// initiate the search
mgr.multistepSearch(searchSettings);
}
where "code" is relative to the code of the city that I am into (for example GBCITY04 for London) and parentId is -1 like shown in Skobbler's Android "How To". I also tried to enter all different listLevel values but nothing changed.
In my app, I avoided to download "Maps.json" file because I have to manage only 2 cities, Milan and London, so i download only Milan and London's maps having relative city codes (ITCITY01 and GBCITY04). Can this be the cause of my problems?
Thanks in advance for the support.

Android Linkify TextView: Linkify Dutch address

I was wondering, does anyone know how to get an address in a textview matched by the Linkify in Android and make it a clickable link?
I think I can figure out how to do this manually, but I was wondering if I have to match the address against a certain pattern so that it does this without me having to do it for Linkify?
I've seen other questions about this, but those are mostly outdated and never really got solved.
Could you point me in the right direction?
Below you can see how I do this manually with a longitude and latitude and the address itself.
mLocation.mImage.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent callIntent = new Intent(Intent.ACTION_VIEW);
//callIntent.setData(Uri.parse("google.navigation:q=" + establishment.getStreet() + "+" + establishment.getHousenumber() + "+" + establishment.getPostalcode() + "+" + establishment.getCity()));
callIntent.setData(Uri.parse("geo:" + establishment.getLongitude() + ", " + establishment.getLatitude()));
startActivity(callIntent);
}
});
Thanks in advance.
Maybe this can help you: http://www.aviyehuda.com/blog/2011/01/27/android-creating-links-using-linkfy/
TextView myLocation = new TextView(this);
myLocation.setText("436 Mayfield Ave, Stanford, CA");
Linkify.addLinks(myLocation , Linkify.MAP_ADDRESSES);
mainLayout.addView(myLocation);
If you look here:
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4.2_r1/android/webkit/WebView.java#WebView.findAddress%28java.lang.String%29
You'll see that currently only US addresses are supported by Linkify.
Gets the first substring consisting of the address of a physical location.
Currently, only addresses in the United States are detected, and consist of:
a house number
a street name
a street type (Road, Circle, etc), either spelled out or abbreviated
a city name
a state or territory, either spelled out or two-letter abbr
an optional 5 digit or 9 digit zip code
All names must be correctly capitalized, and the zip code, if present,
must be valid for the state. The street type must be a standard USPS spelling
or abbreviation. The state or territory must also be spelled or abbreviated
using USPS standards. The house number may not exceed five digits.
Parameters: addr the string to search for addresses
Returns: the address, or if no address is found, null
Hope this helps anyone trying to figure the same thing out.
I guess the only thing one can do is, building your own matcher for addresses.

Categories

Resources