2016-09-19 34 views
0

我正在使用estimote sdk工作在Estimote信號燈上,我添加了APP_ID和APP_TOKEN,但仍然無法檢測到。爲什麼在Android上未檢測到Estimote信標?

@Override 
public void onCreate() { 
    super.onCreate(); 

    beaconManager = new com.estimote.sdk.BeaconManager(getApplicationContext()); 

    EstimoteSDK.initialize(getApplicationContext(), Constants.APP_ID, Constants.APP_TOKEN); 

    beaconManager.setMonitoringListener(new com.estimote.sdk.BeaconManager.MonitoringListener() { 
    @Override 
    public void onEnteredRegion(com.estimote.sdk.Region region, java.util.List<com.estimote.sdk.Beacon> list) { 
      showNotification("Welcome to the shop", "You are in"); 
    } 

    @Override 
    public void onExitedRegion(com.estimote.sdk.Region region) { 

    } 
    }); 
} 

權限

<uses-permission android:name="android.permission.BLUETOOTH"/> 
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 

敬請通過我的職位,並建議我一些解決方案。

解決方案

beaconManager.setNearableListener(new BeaconManager.NearableListener() { 
     @Override 
     public void onNearablesDiscovered(java.util.List<com.estimote.sdk.Nearable> nearables) { 

     } 
    }); 

    beaconManager.connect(new BeaconManager.ServiceReadyCallback() { 
     @Override 
     public void onServiceReady() { 
      scanId = beaconManager.startNearableDiscovery(); 
     } 
    }); 
+0

試試這個樣本http://developer.estimote.com/android/tutorial/part -3-ranging-beacon/ – Lingeshwaran

+0

@Lingeshwaran嘿,謝謝我已經嘗試過這個想法,但在他們的UUID是硬編碼的,但我想動態檢測,你能告訴我如何動態檢測這些信標? –

+0

你沒有UUID? – Lingeshwaran

回答

0

嘗試使用需要被監控UUID和輕微重大:

// this is were we left off: 
    beaconManager = new BeaconManager(getApplicationContext()); 
    // add this below: 
    beaconManager.connect(new BeaconManager.ServiceReadyCallback() { 
    @Override 
    public void onServiceReady() { 
     beaconManager.startMonitoring(new BeaconRegion(
      "monitored region", 
      UUID.fromString("B9407F30-F5F8-466E-AFF9-25556B57FE6D"), 
      22504, 48827)); 
    } 
    }); 
相關問題