Skip to content

dahLucky/ibeacon-scanner-android

This branch is 1 commit ahead of, 15 commits behind inthepocket/ibeacon-scanner-android:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

eeb6888 · Nov 25, 2017
Dec 30, 2016
Sep 27, 2016
Nov 25, 2017
Sep 27, 2016
Dec 13, 2016
Oct 11, 2016
May 19, 2017
Dec 30, 2016
May 19, 2017
Sep 27, 2016
Sep 27, 2016
Nov 22, 2016
Sep 27, 2016

Repository files navigation

iBeacon scanner android

Build Status MIT License

Android library to scan for iBeacons.

Download the library

You can download the library via Gradle from the jCenter repository:

repositories {
    jcenter()
}

By adding the dependency in your module level build.gradle:

dependencies {
    compile 'mobi.inthepocket.android:ibeaconscanner:1.2.2'
}

Setup

It depends if you want to scan for beacons in a service or in your app how to integrate the library:

Service

public class MyService extends Service implements IBeaconScanner.Callback
{
    @Override
    public void onCreate()
    {
        super.OnCreate();

        // initialize
        IBeaconScanner.initialize(IBeaconScanner.newInitializer(this).build());
        IBeaconScanner.getInstance().setCallback(this);
    }
}

Application

If you want to scan for beacons in an activity, first initialize the library in your application class:

public class MyApplication extends Application
{
    public void onCreate()
    {
        super.onCreate();

        // initialize
        IBeaconScanner.initialize(IBeaconScanner.newInitializer(this).build());
    }
}

Get notified of iBeacon enters and exits

Set Callback

You need to set your Callback in your Activity, Fragment or Service, by implementing this interface:

public interface Callback
{
    void didEnterBeacon(Beacon beacon);

    void didExitBeacon(Beacon beacon);

    void monitoringDidFail(Error error);
}
IBeaconScanner.getInstance().setCallback(this);

Create a Beacon object

final Beacon beacon = Beacon.newBuilder()
    .setUUID("84be19d4-797d-11e5-8bcf-feff819cdc9f")
    .setMajor(1)
    .setMinor(2)
    .build();

Pass beacons you want to monitor

Pass one or more beacons to the library to start getting enter or exit notifies:

IBeaconScanner.getInstance().startMonitoring(beacon);

License

IBEACON-SCANNER-ANDROID is freely distributable under the terms of the MIT license.

About

Android library to scan for iBeacons.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%