「Android Beacon DeviceInfo SDK Tutorial」修訂間的差異
跳至導覽
跳至搜尋
imported>Wikiuser |
imported>Wikiuser |
||
(未顯示同一使用者於中間所作的 5 次修訂) | |||
行 1: | 行 1: | ||
=== Download Android Beacon DeviceInfo SDK === | === Download Android Beacon DeviceInfo SDK === | ||
含有Beacon DeviceInfo SDK以及範例程式碼 | :含有Beacon DeviceInfo SDK以及範例程式碼 | ||
:{| class="wikitable" | :{| class="wikitable" | ||
|- | |- | ||
! Version !! Package !! Size !! Notes | ! Version !! Package !! Size !! Notes | ||
|- | |- | ||
|1.0.0 || || <center> | |1.0.0 || [[媒體: AndroidTwmBeaconDeviceInfoSDK_1.0.0.zip|twmBeaconDeviceInfoSDK_1.0.0]] || <center>108 KB</center> || | ||
* Initial release | * Initial release | ||
|} | |} | ||
行 76: | 行 76: | ||
//請依序傳入UUID, Major, Minor, Access Token, 以及Callback | //請依序傳入UUID, Major, Minor, Access Token, 以及Callback | ||
TWMBeacon4GSDK.getInstance().getBeaconInfo("<uuid>", "<major>", "<minor>", "<accessToken>", mBeaconInfoCallback); | TWMBeacon4GSDK.getInstance().getBeaconInfo("<uuid>", "<major>", "<minor>", "<accessToken>", mBeaconInfoCallback); | ||
:Callback範例如下 | :Callback範例如下: | ||
private TWMBeacon4GCallback<BeaconInfoResponse> mBeaconInfoCallback = new TWMBeacon4GCallback<BeaconInfoResponse>(){ | private TWMBeacon4GCallback<BeaconInfoResponse> mBeaconInfoCallback = new TWMBeacon4GCallback<BeaconInfoResponse>(){ | ||
@Override | @Override | ||
行 109: | 行 109: | ||
} | } | ||
}; | }; | ||
=== Proguard Configuration === | |||
:如果您的APP本身需要經過proguard混淆,請增加下面的設定 | |||
##----------- Begin: proguard configuration for TWMBeaconDeviceInfoSDK --------- | |||
-keep class com.taiwanmobile.pt.beacon4g.** { *; } | |||
##---------------End: proguard configuration for TWMBeaconDeviceInfoSDK ---------- | |||
##----------- Begin: proguard configuration for Retrofit --------- | |||
-dontnote retrofit2.Platform | |||
-dontwarn retrofit2.Platform$Java8 | |||
-keepattributes Exceptions | |||
-keepattributes Signature | |||
-dontwarn okio.** | |||
-dontwarn javax.annotation.** | |||
##---------------End: proguard configuration for Retrofit ---------- | |||
##---------------Begin: proguard configuration for Gson ---------- | |||
-keepattributes Signature | |||
-keepattributes *Annotation* | |||
-keep class sun.misc.Unsafe { *; } | |||
-keep class com.google.gson.examples.android.model.** { *; } | |||
##---------------End: proguard configuration for Gson ---------- |
於 2017年7月12日 (三) 08:32 的最新修訂
Download Android Beacon DeviceInfo SDK
- 含有Beacon DeviceInfo SDK以及範例程式碼
Version Package Size Notes 1.0.0 twmBeaconDeviceInfoSDK_1.0.0 108 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); } };
Proguard Configuration
- 如果您的APP本身需要經過proguard混淆,請增加下面的設定
##----------- Begin: proguard configuration for TWMBeaconDeviceInfoSDK --------- -keep class com.taiwanmobile.pt.beacon4g.** { *; } ##---------------End: proguard configuration for TWMBeaconDeviceInfoSDK ---------- ##----------- Begin: proguard configuration for Retrofit --------- -dontnote retrofit2.Platform -dontwarn retrofit2.Platform$Java8 -keepattributes Exceptions -keepattributes Signature -dontwarn okio.** -dontwarn javax.annotation.** ##---------------End: proguard configuration for Retrofit ---------- ##---------------Begin: proguard configuration for Gson ---------- -keepattributes Signature -keepattributes *Annotation* -keep class sun.misc.Unsafe { *; } -keep class com.google.gson.examples.android.model.** { *; } ##---------------End: proguard configuration for Gson ----------