Note that there are some explanatory texts on larger screens.

plurals
  1. POproblems with android.location.geocoder
    primarykey
    data
    text
    <p>I know there has been a lot of questions on the site about the <code>IOExeption</code> : service not available.....I have checked all the answers i could find on the subject... i'm running it as <code>async task</code> which seems to be working fine but still getting the same exception. </p> <p>I have used <code>isPresent()</code> on previous attempts although it is not in the following code and i am using the same phone. i have the internet permission. i have tried to change target to <code>google api</code> to see if that was the problem but it made no difference.</p> <p>This is a vital part of a forth year project so any help would be serious. ps never worked with java or android before very recently so forgive any rookie looking coding ty..</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); view1 = (TextView) findViewById(R.id.textView1); view2 = (TextView)findViewById(R.id.textView2); view3 = (TextView)findViewById(R.id.textView4); b1 = (Button) findViewById(R.id.button1); locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); //provider = // locationManager.getProvider(LocationManager.GPS_PROVIDER); final LocationListener listener = new LocationListener() { @Override public void onLocationChanged(Location location) { view2.setText(Double.toString(location.getLatitude())); view3.setText(Double.toString(location.getLongitude())); Double lat = Double.valueOf(location.getLatitude()); Double longTemp = Double.valueOf(location.getLatitude()); new geo().execute(lat,longTemp); } @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 } }; b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub locReqest(); } private void locReqest() { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, listener); } }); } class geo extends AsyncTask&lt;Double, Void, String&gt;{ Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault()); @Override protected String doInBackground(Double... params) { Address address = null; List&lt;Address&gt; addresses = null; try { // Call the synchronous getFromLocation() method by passing in the lat/long values. addresses = geocoder.getFromLocation(params[0].doubleValue(),params[1].doubleValue(), 1); address = addresses.get(0); if (address != null){ return "Got your address : " + address.getCountryName().toString(); } } catch (IOException e) { e.printStackTrace(); return "failed"; } return"fail"; } @Override protected void onPostExecute(String result) { // TODO Auto-generated method stub super.onPostExecute(result); //view1.setText(result); Toast.makeText(getApplicationContext(), "The address is: " + result, Toast.LENGTH_LONG).show(); } } </code></pre> <p>heres the logcat</p> <pre><code>12-16 23:06:53.855: W/System.err(23578): java.io.IOException: Service not Available 12-16 23:06:53.865: W/System.err(23578): at android.location.Geocoder.getFromLocation(Geocoder.java:136) 12-16 23:06:53.865: W/System.err(23578): at com.boggerTech.local.Main$geo.doInBackground(Main.java:102) 12-16 23:06:53.880: W/System.err(23578): at com.boggerTech.local.Main$geo.doInBackground(Main.java:1) 12-16 23:06:53.900: W/System.err(23578): at android.os.AsyncTask$2.call(AsyncTask.java:264) 12-16 23:06:53.900: W/System.err(23578): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 12-16 23:06:53.905: W/System.err(23578): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 12-16 23:06:53.915: W/System.err(23578): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208) 12-16 23:06:53.915: W/System.err(23578): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 12-16 23:06:53.915: W/System.err(23578): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 12-16 23:06:53.920: W/System.err(23578): at java.lang.Thread.run(Thread.java:856) 12-16 23:07:10.440: W/System.err(23578): java.io.IOException: Service not Available </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload