Factual Blog /

Factual Android SDK

Factual would like to announce the release of the new, officially supported SDK for Android!  Some of you may already be using the Factual Java driver in your Android project, so what’s so different about this version?  We’ve done several things for you:

  1. Defined the exact dependencies needed to get up and running on an Android device.
  2. Provided a sample Android project.  Copy this project as a model for incorporating Factual data in your own application, or use it as a starter to immediately begin work on your new application.


If you’re using Maven, add the driver to your project using:


Otherwise, check the pom.xml file for the required dependencies.

Once you have the driver installed in your Java project, here’s how you create an authenticated handle to Factual:

Factual factual = new Factual("YOUR_API_KEY", "YOUR_API_SECRET");

Next, simply create the request of your choice, and fetch the results.


Consider searching for Italian restaurants nearby your current location.  Use the Android location service to get your current phone location:

LocationManager locationManager =
  (LocationManager) getSystemService(Context.LOCATION_SERVICE);
String locationProvider = LocationManager.GPS_PROVIDER;
Location location = locationManager.getLastKnownLocation(locationProvider);
double latitude = location.getLatitude();
double longitude = location.getLongitude();

Now create a query to find Italian restaurants within 1000 meters of your current location, sorted by distance:

Query query = new Query()
.within(new Circle(latitude, longitude, 1000))
.only("name", "address", "tel");

Fetch and print the results against the Restaurants data set:

ReadResponse italian = factual.fetch("restaurants-us", query);

for (Map restaurant : italian.getData()) {
    String name = (String) restaurant.get("name");
    String address = (String) restaurant.get("address");
    String phone = (String) restaurant.get("tel");
    Number distance = (Number) restaurant.get("$distance");
    System.out.println(distance + " meters away: "+name+" @ " +address + ", call "+phone);

Sample results searching near our Factual office are:

186.77191 meters away: Obika Mozzarella Bar - Century City @ 10250 Santa Monica Blvd, call (310) 556-2452
186.77191 meters away: Toscanova @ 10250 Santa Monica Blvd, call (310) 551-0499
813.8221 meters away: Carmine's II @ 10463 Santa Monica Blvd, call (310) 441-4706

Great!  There are several options nearby.  Now let’s say we want our application to be able to call and make a reservation at Toscanova.  We already have the phone number, so just use the Android APIs to access the phone on the device to make the call:

String uri = "tel:" + phone;
Intent intent = new Intent(Intent.ACTION_CALL);

As another example, let’s say you’re on the road, and it’s late.  You’re set to arrive at your hotel at 2 am, and you’ll be hungry.  Use Factual to find restaurants open 24 hours near the location of your hotel.  First, retrieve the latitude and longitude of the hotel using our Places dataset.  Our Restaurants schema, has an attribute “open_24hrs”, so your query is as follows:

new Query()
.within(new Circle(latitude, longitude, meters))

Looking through the results, you find the place you’re looking for:

1769.1987 meters away: IHOP @ 1850 Soldiers Field Rd, call (617) 787-0533


The above examples show how developing on a mobile device is a great way to take full advantage of the data Factual has to offer, opening up new possibilities for creating lots of cool applications.  All APIs available in the Java driver are available in the Android SDK, and complete documentation can be found on the driver’s Github page.

We hope you find these updates useful, and feel free to let us know if you end up using the driver for any new Android applications, as we’re always excited to see ways that people are using our data.  Let us know if you have any questions or suggestions, and we hope you’ll enjoy using Factual in your mobile applications!

New to Factual?  Explore our data offerings and sign up to get started!

Best wishes,
Brandon Yoshimoto
Software Engineer