android - How to enable google map service -



android - How to enable google map service -

i had problem geocoder.ispresent() returns false. googled solution , found google map service not enabled. how can enable service? can guide me?

package com.incv.mobile.freejscf; import java.io.ioexception; import java.util.list; import java.util.locale; import android.app.application; import android.content.context; import android.location.address; import android.location.geocoder; import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.os.asynctask; import android.os.build; import android.os.bundle; import android.util.log; import android.view.view; public class myapplication extends application implements locationlistener { double latitude = 0; double longitude = 0; @override public void oncreate() { super.oncreate(); location mlocation = null; if (geocoder.ispresent()) { (new getaddresstask(this)).execute(mlocation); } else{ log.e("not", "geocoder not present"); } } private class getaddresstask extends asynctask<location, void, string> { context mcontext; public getaddresstask(context context) { super(); mcontext = context; } /** * geocoder instance, latitude , longitude * address, , homecoming * * @params params 1 or more location objects * @return string containing address of current * location, or empty string if no address can found, * or error message */ @override protected string doinbackground(location... params) { geocoder geocoder = new geocoder(mcontext, locale.getdefault()); // current location input parameter list location loc = params[0]; // create list contain result address list<address> addresses = null; seek { /* * homecoming 1 address. */ addresses = geocoder.getfromlocation(loc.getlatitude(), loc.getlongitude(), 1); } grab (ioexception e1) { log.e("locationsampleactivity", "io exception in getfromlocation()"); e1.printstacktrace(); homecoming ("io exception trying address"); } grab (illegalargumentexception e2) { // error message post in log string errorstring = "illegal arguments " + double.tostring(loc.getlatitude()) + " , " + double.tostring(loc.getlongitude()) + " passed address service"; log.e("locationsampleactivity", errorstring); e2.printstacktrace(); homecoming errorstring; } // if reverse geocode returned address if (addresses != null && addresses.size() > 0) { // first address address address = addresses.get(0); /* * format first line of address (if available), * city, , country name. */ string addresstext = string.format( "%s, %s, %s", // if there's street address, add together address.getmaxaddresslineindex() > 0 ? address.getaddressline(0) : "", // locality city address.getlocality(), // country of address address.getcountryname()); // homecoming text homecoming addresstext; } else { homecoming "no address found"; } } protected void onpostexecute(string address) { // maddress.settext(address); log.e("address", address.tostring()); } } public void getaddress(view v) { // ensure geocoder services available } @override public void onlocationchanged(location arg0) { // todo auto-generated method stub } @override public void onproviderdisabled(string provider) { // todo auto-generated method stub } @override public void onproviderenabled(string provider) { // todo auto-generated method stub } @override public void onstatuschanged(string provider, int status, bundle extras) { // todo auto-generated method stub } }

in above code first oncreate methid executed. goes else part. means geocoder.isprovider() homecoming false.

just follow developers guide setting map in android apps. next quick guide line

download google playservices android sdk manager add eclipse , add together library project add keys , other prerequisties within google console embed necessary permissions , keys within androidmanifest.xml

android geocoding

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -