BeaconManager example with latest Android SDK

Hi all,

I am trying the new Android Monitoring and Ranging example with the latest Estimote Android SDK v1.03

http://developer.estimote.com/android/tutorial/part-1-setting-up/

In the new class in coresdk fo v1.03, I have a problem which function is for monitoring and which one is for listening so that I can get the example calls completely replaced.

I am using Eclipse. Could you please help shed some lights?
Thanks a lot.

beaconManager.setMonitoringListener(new BeaconManager.MonitoringListener() {

beaconManager.startMonitoring(

beaconManager.setRangingListener(new BeaconManager.RangingListener()

Thanks,
Albert

Hi @albertcy2002,

there is no function for listening, you can monitor or range region.
You have to set a listener for when the Bluetooth service notifies you an event.

  1. declare your BeaconManager,
    BeaconManager manager = new BeaconManager(this);
  2. set a listener and implement the method to handle the answer,
    manager.setMonitoringListener(new BeaconManager.BeaconMonitoringListener { @Override public void onEnteredRegion(BeaconRegion region, List<Beacon> beacons) { // Handle action here } @Override public void onExitedRegion(BeaconRegion region) { // Handle action here } }
  3. start your ranging/monitoring.

Maybe I didn’t understand well what you wanted.

Hi Ximun,

Thanks. My understanding of monitoring is to monitor if the device is within the range of beacon which matches the monitoring criteria, and ranging is to get detailed info of the list of detected beacon.

In the old example, there are three uses of beaconManager of (the sdk class)
beaconManager.setMonitoringListener(new BeaconManager.MonitoringListener() {
beaconManager.startMonitoring(
beaconManager.setRangingListener(new BeaconManager.RangingListener()

But in coresdk, I am not sure how can I replace the calls, so that I can do monitoring / ranging whenever I want.

Thanks.

regards,
Albert

Hi Ximun,

May I know if I am asking the right question? thanks.

regards,
Albert

Hi @albertcy2002,

you can use those methods in the new SDK, the BeaconManager class still exists:

and maybe you want this too:

Thanks a lot Ximun,

It works, and I have been overlooking on the new classes.
thanks for reminding me.

However, I go the below even I have added the right permission and i have tried using either clause below but I still got the error. Could you please shed some lights? thanks a lot. (I am using Elipse)

    <service android:name="com.estimote.sdk.scanning.BeaconService"
     android:exported="false"/>

OR

Error
E/EstimoteSDK(15992): SystemRequirementsHelper.hasServiceDeclaration:216 AndroidManifest.xml does not contain BeaconService declaration.

W/EstimoteSDK(15992): BeaconManager.connect:335 Could not bind service: make sure thatcom.estimote.sdk.scanning.BeaconService is declared in AndroidManifest.xml

regards,
Albert

Hey,

the permissions you have to add to you AndroidManifest.xml are:

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

and

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

following this.
It seems to me that there is no need for other permission.

My AndroidManifest.xml file:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.*********.*********>

<!-- Permissions to use Bluetooth --> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

<application android:allowBackup="true" android:icon="@mipmap/*********" android:label="@string/*********" android:roundIcon="@mipmap/*********" android:supportsRtl="true" android:theme="@style/*********"> <activity android:name=".*********"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".*********"> </activity> </application>

</manifest>

Ximun, thanks a lot.

Still figuring out what happen.
BTW, do you need to put either of the below declaration in your androidmanifest.xml?
thanks.

    <service android:name="com.estimote.sdk.scanning.BeaconService"
     android:exported="false"/>

<service android:name="com.estimote.sdk.service.BeaconService"
         android:exported="false"/>

regards,
Albert

I did not put those declarations, and my app’ is running well (ish ;)).

The error

W/EstimoteSDK(15992): BeaconManager.connect:335 Could not bind service:
make sure thatcom.estimote.sdk.scanning.BeaconService is declared in
AndroidManifest.xml

says that you are still using the estimote.sdk library. Is the old version.

Thanks Ximun, and sorry to bother you again.

I still get the error, details as follows:
I am using Android 5 runing on non-Android M device.

After tracing, the two errors
W/EstimoteSDK(15992): BeaconManager.connect:335 Could not bind service:
make sure thatcom.estimote.sdk.scanning.BeaconService is declared in
AndroidManifest.xml
throw on this line:

beaconManager.connect(new BeaconManager.ServiceReadyCallback() {

My AndroidManifest.xml file:

<?xml version="1.0" encoding="utf-8"?>

<uses-sdk
    android:minSdkVersion="18"
    android:targetSdkVersion="22" />

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


<application
    android:name=".MyApplication"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>

Thanks in advance for helping. thx a lot

Hey,

I don’t know what this error is, I personnaly use Android Studio so Gradle does the SDK integration task for me (if I understand well what happens ^^).
I have no need of the following lines:

<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="22" />

They are also in the build.gradle file:

android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "com.example.beacontest" minSdkVersion 18 targetSdkVersion 25 [...] } }

dependencies { [...] compile 'com.estimote:sdk:1.0.3:release@aar' }