「Android Beacon DeviceInfo SDK Tutorial」修訂間的差異
跳至導覽
跳至搜尋
imported>Wikiuser (新頁面: === Download Android Beacon DeviceInfo SDK === :{| class="wikitable" |- ! Version !! Package !! Size !! Notes |- |1.0.0 || || <center>0 KB</center> || * Initial release |} <br> === ...) |
imported>Wikiuser |
||
行 1: | 行 1: | ||
=== Download Android Beacon DeviceInfo SDK === | === Download Android Beacon DeviceInfo SDK === | ||
含有Beacon DeviceInfo SDK以及範例程式碼 | |||
:{| class="wikitable" | :{| class="wikitable" | ||
|- | |- | ||
行 68: | 行 69: | ||
<uses-permission android:name="android.permission.INTERNET"/> | <uses-permission android:name="android.permission.INTERNET"/> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | ||
<br> | |||
===Documentation=== | |||
*設備資訊請求 | |||
:請在程式內加入此行,SDK會依據UUID、Major、Minor和Access Token回傳對應的設備資訊 | |||
//請依序傳入UUID, Major, Minor, Access Token, 以及Callback | |||
TWMBeacon4GSDK.getInstance().getBeaconInfo("<uuid>", "<major>", "<minor>", "<accessToken>", mBeaconInfoCallback); | |||
:Callback範例如下 | |||
private TWMBeacon4GCallback<BeaconInfoResponse> mBeaconInfoCallback = new TWMBeacon4GCallback<BeaconInfoResponse>(){ | |||
@Override | |||
public void onResponse(BeaconInfoResponse result) { | |||
BeaconInfo bInfo = result.getBeaconInfo(); | |||
Log.d("MyBeaconLog", | |||
"Status Code: " + result.getStatusCode() + "\n" + | |||
"Message: " + result.getMessage() + "\n" + | |||
"Company: " + bInfo.getCompany() + "\n" + | |||
"Tax ID: " + bInfo.getTaxId() + "\n" + | |||
"Mac Address: " + bInfo.getMacAddress() + "\n" + | |||
"UUID: " + bInfo.getUuid() + "\n" + | |||
"Major: " + bInfo.getMajor() + "\n" + | |||
"Minor: " + bInfo.getMinor() + "\n" + | |||
"Power: " + bInfo.getPower() + "\n" + | |||
"Location: " + bInfo.getLocation() + "\n" + | |||
"Physical Address: " + bInfo.getPhysicalAddress() + "\n" + | |||
"Picture: " + bInfo.getPicture() + "\n" + | |||
"URL: " + bInfo.getUrl() + "\n" + | |||
"Battery Level: " + bInfo.getBatteryLevel() + "\n" + | |||
"Register Date: " + bInfo.getRegisterDate() + "\n" + | |||
"Service Date: " + bInfo.getServiceDate() + "\n" + | |||
"Maintenance Date: " + bInfo.getMaintenanceDate() + "\n" + | |||
"Access Token: " + bInfo.getAccessToken() | |||
); | |||
} | |||
@Override | |||
public void onErrorResponse(TWMRetrofitError error, String message) { | |||
// Connection Error | |||
Log.e("MyBeaconLog", message); | |||
} | |||
}; |
於 2017年7月12日 (三) 06:42 的修訂
Download Android Beacon DeviceInfo SDK
含有Beacon DeviceInfo SDK以及範例程式碼
Version Package Size Notes 1.0.0 0 KB - Initial release
Getting Started
- 簡介
- AndroidBeacon設備資訊SDK提供Android App開發者取得iBeacon的Mac Address、電量、位置、公司名和相關網址等設備資訊。
- 系統需求
- Android 2.3以上(API 9+)、Java 7以上
- 開始使用
以Android Studio整合 (Version: 2.3.3)
- Step 1: 整合Retrofit
- 在build.gradle的dependencies內加入下列程式碼:
compile 'com.squareup.retrofit2:retrofit:2.3.0 compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile files('libs/twm_beaconinfo_sdk.jar')
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
以Eclipse整合 (Version: Neon.3 Release (4.6.3), Eclipse for Android Developers )
- Step 1: 下載Retrofit相關套件
- 請到下列網址下載各個套件的jar檔
- 請到下列網址下載各個套件的jar檔
Library URL Retrofit2 http://square.github.io/retrofit/ Retrofit2-Converter-Gson https://github.com/square/retrofit/tree/master/retrofit-converters/gson Google-Gson https://www.versioneye.com/java/com.google.code.gson:gson/2.8.1 OkHttp3 http://square.github.io/okhttp/ Okio https://github.com/square/okio
- Step 2: 整合Retrofit與Android Beacon DeviceInfo SDK
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Documentation
- 設備資訊請求
- 請在程式內加入此行,SDK會依據UUID、Major、Minor和Access Token回傳對應的設備資訊
//請依序傳入UUID, Major, Minor, Access Token, 以及Callback TWMBeacon4GSDK.getInstance().getBeaconInfo("<uuid>", "<major>", "<minor>", "<accessToken>", mBeaconInfoCallback);
- Callback範例如下
private TWMBeacon4GCallback<BeaconInfoResponse> mBeaconInfoCallback = new TWMBeacon4GCallback<BeaconInfoResponse>(){ @Override public void onResponse(BeaconInfoResponse result) { BeaconInfo bInfo = result.getBeaconInfo(); Log.d("MyBeaconLog", "Status Code: " + result.getStatusCode() + "\n" + "Message: " + result.getMessage() + "\n" + "Company: " + bInfo.getCompany() + "\n" + "Tax ID: " + bInfo.getTaxId() + "\n" + "Mac Address: " + bInfo.getMacAddress() + "\n" + "UUID: " + bInfo.getUuid() + "\n" + "Major: " + bInfo.getMajor() + "\n" + "Minor: " + bInfo.getMinor() + "\n" + "Power: " + bInfo.getPower() + "\n" + "Location: " + bInfo.getLocation() + "\n" + "Physical Address: " + bInfo.getPhysicalAddress() + "\n" + "Picture: " + bInfo.getPicture() + "\n" + "URL: " + bInfo.getUrl() + "\n" + "Battery Level: " + bInfo.getBatteryLevel() + "\n" + "Register Date: " + bInfo.getRegisterDate() + "\n" + "Service Date: " + bInfo.getServiceDate() + "\n" + "Maintenance Date: " + bInfo.getMaintenanceDate() + "\n" + "Access Token: " + bInfo.getAccessToken() ); } @Override public void onErrorResponse(TWMRetrofitError error, String message) { // Connection Error Log.e("MyBeaconLog", message); } };