An example of how to use the Stumbler library
Перейти к файлу
Victor Ng ca0a797563 whitespace change - just to trigger travis 2015-03-25 13:52:10 -04:00
.idea Reworked DemoStumbler to pull in the library from JCenter 2015-03-23 22:43:27 -04:00
app patches to sync against the v1.7.10 library 2015-03-25 13:37:53 -04:00
docs Simplified the MainActivity a little, added PNG showing how to install 2015-02-12 15:49:03 -05:00
gradle/wrapper init checkin 2015-02-04 15:10:19 -05:00
.gitignore added stumbler-debug aar library 2015-02-04 15:52:26 -05:00
.travis.yml added travis yaml 2015-03-23 23:00:30 -04:00
DemoStumbler.iml * Added a DebugHttpUtil so that network calls to geosubmit just go to 2015-03-20 16:05:30 -04:00
Makefile Library is in jcenter now 2015-03-25 10:37:51 -04:00
README.md whitespace change - just to trigger travis 2015-03-25 13:52:10 -04:00
build.gradle basic demo code added 2015-02-11 20:06:07 -05:00
gradle.properties init checkin 2015-02-04 15:10:19 -05:00
gradlew init checkin 2015-02-04 15:10:19 -05:00
gradlew.bat init checkin 2015-02-04 15:10:19 -05:00
settings.gradle Reworked DemoStumbler to pull in the library from JCenter 2015-03-23 22:43:27 -04:00

README.md

BuildStatus

DemoStumbler

Embed the Mozilla Stumbler as a library in your Android Application

The Mozilla Stumbler is an Android wifi and cell tower stumbling application which is designed to collect location data and submit it to our location service Ichnaea.

The standard Android application runs in what we call 'active' mode where we aggressively scan for Wi-fi routers, cell tower data and GPS supplied latitude and longitude.

We have a second mode though - for passive stumbling. We use a version of this code in Firefox for Android to do extremely low power stumbling.

Now you can use it too!

Full documentation can be found on the primary Mozilla Stumbler wiki

But I'm impatient. Just show me the code.

You'll need to import some classes:

import org.mozilla.mozstumbler.service.core.http.IHttpUtil;
import org.mozilla.mozstumbler.service.mainthread.PassiveServiceReceiver;
import org.mozilla.mozstumbler.svclocator.ServiceConfig;
import org.mozilla.mozstumbler.svclocator.ServiceLocator;
import org.mozilla.mozstumbler.svclocator.services.ISystemClock;
import org.mozilla.mozstumbler.svclocator.services.log.ILogger;

Next, you'll need to configure the ServiceLocator and then start the service with an Intent.

// Setup ServiceConfig and ServiceLocator
ServiceConfig svcConfig = new ServiceConfig();
svcConfig.put(IHttpUtil.class,
        ServiceConfig.load("org.mozilla.mozstumbler.service.core.http.HttpUtil"));
svcConfig.put(ISystemClock.class,
        ServiceConfig.load("org.mozilla.mozstumbler.svclocator.services.SystemClock"));
svcConfig.put(ILocationService.class,
        ServiceConfig.load("org.mozilla.mozstumbler.service.core.http.MLS"));
svcConfig.put(ILogger.class,
        ServiceConfig.load("org.mozilla.mozstumbler.svclocator.services.log.ProductionLogger"));

ServiceLocator.newRoot(svcConfig);

Intent i = PassiveServiceReceiver.createStartIntent(this, "a_moz_api_key",
        "Just Another User-Agent");
startService(i);

Build and install the code

Enable Developer Options if you haven't done so already

  1. Open Settings> About> Software Information> More.
  2. Then tap “Build number” seven times to enable Developer options. ...
  3. Go back to Settings menu and now you'll be able to see “Developer options” there.
  4. Tap it and turn on USB Debugging from the menu on the next screen.

Connect your Android device over USB, build and install.

From command line on UNIX:

./gradlew installDebug

You can alternately just open Android Studio and use the IDE to build and install the application.