Git Product home page Git Product logo

kontakt-android-sdk's Introduction

Kontakt.io Android SDK

The Kontakt.io Android SDK is a library for Android OS that provides developers with components to help build applications using Kontakt.io devices.

For full documentation please see docs website.

Latest Version

Latest version is 7.0.12.2

Quickstart

  1. Add Gradle dependency into your app's build.config
dependencies {
    compile 'io.kontakt.mvn:sdk:{latest_version}'
}
  1. Add necessary permissions into your AndroidManifest
<uses-permission android:name="android.permission.BLUETOOTH"/> // add android:maxSdkVersion="30" when compiling against sdk 31 or higher
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> // add android:maxSdkVersion="30" when compiling against sdk 31 or higher
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

// Access fine location is necessary when sdk version is equal / bigger than Android 10; below that you can use ACCESS_COARSE_LOCATION for BT scanning; when targetting Android 12 or higher, and BLUETOOTH_SCAN does not have neverForLocation tag, ACCESS_FINE_LOCATION should also be present in the manifest file
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
// When compiling against and targetting sdk=31 and higher
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" /> // you could also add "neverForLocation"=true and remove ACCESS_FINE_LOCATION permission if location is used only for bt scanning purposes
// When compiling against and targetting sdk=31 and higher
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
  1. Add ProximityService int your AndroidManifest application section
<service android:name="com.kontakt.sdk.android.ble.service.ProximityService" android:exported="false"/>
  1. Make sure Bluetooth is enabled on your device.

  2. Ask about the necessary runtime permissions

  3. Create simple activity that will scan for both iBeacons and Eddystones

public class MainActivity extends AppCompatActivity {

  private ProximityManager proximityManager;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    KontaktSDK.initialize("YOUR_API_KEY");

    proximityManager = ProximityManagerFactory.create(this);
    proximityManager.setIBeaconListener(createIBeaconListener());
    proximityManager.setEddystoneListener(createEddystoneListener());
  }

  @Override
  protected void onStart() {
    super.onStart();
    startScanning();
  }

  @Override
  protected void onStop() {
    proximityManager.stopScanning();
    super.onStop();
  }

  @Override
  protected void onDestroy() {
    proximityManager.disconnect();
    proximityManager = null;
    super.onDestroy();
  }

  private void startScanning() {
    proximityManager.connect(new OnServiceReadyListener() {
      @Override
      public void onServiceReady() {
        proximityManager.startScanning();
      }
    });
  }

  private IBeaconListener createIBeaconListener() {
    return new SimpleIBeaconListener() {
      @Override
      public void onIBeaconDiscovered(IBeaconDevice ibeacon, IBeaconRegion region) {
        Log.i("Sample", "IBeacon discovered: " + ibeacon.toString());
      }
    };
  }

  private EddystoneListener createEddystoneListener() {
    return new SimpleEddystoneListener() {
      @Override
      public void onEddystoneDiscovered(IEddystoneDevice eddystone, IEddystoneNamespace namespace) {
        Log.i("Sample", "Eddystone discovered: " + eddystone.toString());
      }
    };
  }
}

Samples App

For SDK usage samples see the Samples App

Kontakt.io Administration App

To manage Kontakt.io devices please use our Administration App.

License

Licensed under Creative Commons Attribution-NoDerivs 3.0 Unported

THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.

BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.

You may obtain copy of the license at https://creativecommons.org/licenses/by-nd/3.0/legalcode

For more information please visit our docs website.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.