2016年7月20日 星期三

Estimote SDK: Building a beacon Android app ---- 1/3

since: 2016/07/20
update: 2016/07/20

reference:
1. Beacon Tech Overview - Estimote Developer

Part 1: Setting up

A. Create a beacon project
    1. Start a new Android Studio project

    2. 設定好專案相關資料後 > Next

    3. Minimum SDK 選擇 API 18: Android 4.3 (Jelly Bean)
        > Next

    4. 選擇 Empty Activity > Next

    5. Customize the Activity: 使用預設即可 > Finish

-----------------------------------------------------------------------------------------------

B. Add Estimote SDK
    1. 查詢 Estimote Android SDK 最新的版本:
        Releases · Estimote/Android-SDK
        目前:  
dependencies {
    compile 'com.estimote:sdk:0.10.8@aar'
}

    2. 加入 Estimote SDK:
        > 開啟 Gradle Script > build.gradle (Module: app), 修改如下:
....
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.0'

    //@add ########################
    // add the following line, and replace "0.10.4" with the latest version
    // of Estimote Android SDK; you'll find the latest version number on:
    //   https://github.com/Estimote/Android-SDK/releases

    compile 'com.estimote:sdk:0.10.8@aar'
}


    3. 接著右上方出現訊息: Gradle files have changed since last project sync
        > 按下 Sync Now

-----------------------------------------------------------------------------------------------

C. Runtime permissions (Android 6.0)
    1. 開啟 MainActivity.java 修改如下:
package myhome.airport;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.estimote.sdk.SystemRequirementsChecker;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    //@add ########################
    @Override
    protected void onResume() {
        super.onResume();

        //@add ########################
        // Runtime permissions (Android 6.0)

        SystemRequirementsChecker.checkWithDefaultDialogs(this);
    }

}


    2. 執行:


沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。