Android Open Source - callerid-for-android Android Geocoder






From Project

Back to project page callerid-for-android.

License

The source code is released under:

GNU General Public License

If you think the Android project callerid-for-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.integralblue.callerid.geocoder;
/*w  ww.jav  a 2  s . co  m*/
import java.io.IOException;
import java.util.List;

import com.google.inject.Inject;

import android.content.Context;
import android.location.Address;

/** Delegate to the android.location.Geocoder
 * @author candrews
 *
 */
public class AndroidGeocoder implements Geocoder {
  android.location.Geocoder geocoder;
  
  @Inject NominatimGeocoder nominatimGeocoder;
  
  public AndroidGeocoder(Context context){
    geocoder = new android.location.Geocoder(context);
  }

  public List<Address> getFromLocation(double latitude, double longitude,
      int maxResults) throws IOException {
    try{
      return geocoder.getFromLocation(latitude, longitude, maxResults);
    }catch(IOException e){
      //probably service not available - fall back to the backup geocoder
      return nominatimGeocoder.getFromLocation(latitude, longitude, maxResults);
    }
  }

  public List<Address> getFromLocationName(String locationName, int maxResults)
      throws IOException {
    try{
      return geocoder.getFromLocationName(locationName, maxResults);
    }catch(IOException e){
      //probably service not available - fall back to the backup geocoder
      return nominatimGeocoder.getFromLocationName(locationName, maxResults);
    }
  }

  public List<Address> getFromLocationName(String locationName,
      int maxResults, double lowerLeftLatitude,
      double lowerLeftLongitude, double upperRightLatitude,
      double upperRightLongitude) throws IOException {
    try{
      return geocoder.getFromLocationName(locationName, maxResults, lowerLeftLatitude, lowerLeftLongitude, upperRightLatitude, upperRightLongitude);
    }catch(IOException e){
      //probably service not available - fall back to the backup geocoder
      return nominatimGeocoder.getFromLocationName(locationName, maxResults, lowerLeftLatitude, lowerLeftLongitude, upperRightLatitude, upperRightLongitude);
    }
  }
}




Java Source Code List

com.blundell.tut.LoaderImageView.java
com.integralblue.callerid.CallerIDApplication.java
com.integralblue.callerid.CallerIDBroadcastReceiver.java
com.integralblue.callerid.CallerIDLookup.java
com.integralblue.callerid.CallerIDResult.java
com.integralblue.callerid.CallerIDService.java
com.integralblue.callerid.GeocoderAsyncTask.java
com.integralblue.callerid.HttpCallerIDLookup.java
com.integralblue.callerid.LookupAsyncTask.java
com.integralblue.callerid.LookupFragment.java
com.integralblue.callerid.MainActivity.java
com.integralblue.callerid.PreferencesActivity.java
com.integralblue.callerid.RecentCallsFragment.java
com.integralblue.callerid.SpecialPhoneNumbers.java
com.integralblue.callerid.TabsAdapter.java
com.integralblue.callerid.contacts.ContactsHelper.java
com.integralblue.callerid.contacts.NewContactsHelper.java
com.integralblue.callerid.contacts.OldContactsHelper.java
com.integralblue.callerid.geocoder.AndroidGeocoder.java
com.integralblue.callerid.geocoder.Geocoder.java
com.integralblue.callerid.geocoder.NominatimGeocoder.java
com.integralblue.callerid.inject.CallerIDModule.java
com.integralblue.callerid.inject.ContactsHelperProvider.java
com.integralblue.callerid.inject.CountryDetector.java
com.integralblue.callerid.inject.GeocoderHelperProvider.java
com.integralblue.callerid.inject.PreferencesNameProvider.java
com.integralblue.callerid.inject.RestTemplateProvider.java
com.integralblue.callerid.inject.TextToSpeechHelper.java
com.integralblue.callerid.inject.VersionInformationHelper.java
com.integralblue.callerid.widget.DontPressWithParentImageView.java
com.squareup.okhttp.OkHttpURLStreamHandlerFactory.java
com.squareup.okhttp.internal.OkHttpClientHandler.java