One beacon, thousands of apps

Our beacons are reusable by other apps that need a verified check-in

Getting started - Android

In less than a coffee lasts you can have your App running with the Outbarriers SDK

1. Download the library

Add to build.gradle the library

android {
    repositories {
        maven {
            url "https://outbarriers.com/sdk/repository/"
        }
    }
}
dependencies {

    compile('com.outbarriers:outbarrierssdk:1.2.0:release@aar') {
        transitive = true;
    }
}
If you prefer you can download the latest version of SDK (.aar)
Warning! Soon it will be available in the repositories of Maven and the source code will be available in GitHub

2. Add your API credentials

Inside of <application> in AndroidManifest.xml, add the API KEY and API SECRET for your app
<meta-data android:name="com.outbarriers.sdk.API_KEY" android:value="YOUR_API_KEY" />
<meta-data android:name="com.outbarriers.sdk.API_SECRET" android:value="YOUR_API_SECRET" />

3. Implement the callbacks in your activity

public class YourActivity extends AppCompatActivity implements OutbeaconListener {

    private OutbarriersManager oManager;
    private final int PERMISSION_REQUEST_COARSE_LOCATION = 0x123;
    ...

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ...
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && this.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            final AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("App need location permission");
            builder.setMessage("To detect beacons is necessary that you allow the location permission.");
            builder.setPositiveButton(android.R.string.ok, null);
            builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @TargetApi(Build.VERSION_CODES.M)
                public void onDismiss(DialogInterface dialog) {
                    requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, PERMISSION_REQUEST_COARSE_LOCATION);
                }
            });
            builder.show();
        } else {
            initOBManager();
        }
    }
    private void initOBManager() {
      OutbarriersManager.getManager(this, new OutbarriersManagerListener() {
              @Override
              public void onSuccess(OutbarriersManager ob) {
                  oManager = ob;
                  oManager.setOnOutbeaconDetected(YourActivity.this);
                  oManager.setGPSEnabled(false);
                  oManager.startDetection();
              }

              @Override
              public void onError(OutbarriersManagerError err) {
                // Handle OutbarriersManager error
              }
          });

    }
    @Override
    public void onRequestPermissionsResult(int requestCode,
                                           String permissions[], int[] grantResults) {
        switch (requestCode) {
            case PERMISSION_REQUEST_COARSE_LOCATION: {
                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    initOBManager();
                } else {
                  // Handle no permission location context
                }
                return;
            }
        }
    }

    @Override
    public void onOutbeaconDetected(OutbeaconMatch od) {
        Toast.makeText(getApplicationContext(), "Outbeacon detected: " + od.outbeacon.uuid, Toast.LENGTH_LONG).show();
    }

    @Override
    public void onDetectionError(OutbarriersError error) {
    	// Handle Outbarriers Beacon detection error
    }

    @Override
    public void onNearestBeacons(OutbeaconList outbeaconList) {
      // Handle nearest beacons
    }

    @Override
    public void onScanningStatus(boolean b) {
      // Handle scanning status
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (oManager != null) {
            oManager.onDestroy();
        }
    }
}