Visit GitHub Repo

Phone tracker

Download Android Arsenal

Phone tracker is an Android library to gather environment signals, like cell towers, wifi access points and gps locations. You can configure how to scan. Also you can make hot configuring updates, and be notified when the configuration is updated, among other things.


For gradle based projects you need to add to your build.gradle

repositories {

And in your dependencies block add this line

compile 'com.fooock:phone-tracker:0.2.1'

Getting started

You only need to create and instance of the PhoneTracker class and pass the Context to it

PhoneTracker phoneTracker = new PhoneTracker(this);

Now you can call the start() method from the tracker instance. The default configuration is used. For default all sensors are enabled.

Important: Note that if you are target Android 6.0 or greater, you need to grant location permissions to the application in order to gather environment data. You can listen for missing permissions from the PhoneTracker class using the PhoneTracker.PermissionListener interface:

// Listen for missing permissions
phoneTracker.addPermissionListener(new PhoneTracker.PermissionListener() {
    public void onPermissionNotGranted(String... permission) {


If the permissions are not granted, the tracker can't start.

To check if the tracker is running:

// Check the state of the tracker
boolean running = phoneTracker.isRunning();

To stop the tracker:

// Stop all sensors and don't receive more updates

Tracker configuration

To create a default Configuration:

// Create a default configuration
Configuration configuration = new Configuration.Builder().create();

Now see how you can customize the configuration:

  • Wifi Create a Wifi configuration
// Create a new wifi configuration
Configuration.Wifi wifiConf = new Configuration.Wifi();
  • Cell Create a cell configuration
// Create a new cell configuration
Configuration.Cell cellConf = new Configuration.Cell();
  • GPS Create a GPS configuration
// Create a gps configuration
Configuration.Gps gpsConf = new Configuration.Gps();

To create the new custom configuration:

// Create a new custom configuration
Configuration configuration = new Configuration.Builder()

In order to make effective the configuration:

// Set the init configuration

Also, if you want to change the current configuration when the tracker is running:

// Update the current configuration

This method only loads the configuration that has changed, without stopping the tracker. You can listen for configuration changes using the PhoneTracker.ConfigurationChangeListener interface:

// Listen for configuration changes
phoneTracker.setConfigurationChangeListener(new PhoneTracker.ConfigurationChangeListener(){
    public void onConfigurationChange(Configuration configuration) {


Receiving data

You can setup listeners to receive wifi, gps updates and cell tower signals. See below.

  • Wifi
// Set the listener to receive wifi scans
phoneTracker.setWifiScanListener(new PhoneTracker.WifiScanListener() {
    public void onWifiScansReceived(long timestamp, List<ScanResult> wifiScans) {

  • GPS
// Set the listener to receive location updates from gps
phoneTracker.setGpsLocationListener(new PhoneTracker.GpsLocationListener() {
    public void onLocationReceived(long timestamp, Location location) {

  • Cell
// Set the listener for cell scans
phoneTracker.setCellScanListener(new PhoneTracker.CellScanListener() {
    public void onCellInfoReceived(long timestamp, List<CellInfo> cells) {


    public void onNeighborCellReceived(long timestamp, List<NeighboringCellInfo> cells) {


Note if your application target from API 17 to 25 you don't need override the onNeighborCellReceived(...). For this I created an adapter class PhoneTracker.CellScanAdapter to override only the method you are interested:

phoneTracker.setCellScanListener(new PhoneTracker.CellScanAdapter() {
    public void onCellInfoReceived(long timestamp, List<CellInfo> cells) {



Copyright 2017 newhouse (nhitbh at gmail dot com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
Learners From Our Courses Work At