Android tutorials seem out of date

Is there an updated project for the Android ‘Getting Started’ tutorial, specifically for the latest SDK version (1.0.3 at the moment).

The docs here http://developer.estimote.com/android/tutorial/part-1-setting-up/ target 1.0.3, but even some of the code snippets use older APIs. In other words, some classes and such in the tutorial don’t exist in the Javadoc.

What would be great is if the source code here http://developer.estimote.com/android/tutorial/estimote-android-tutorial-ea99e83c.zip (targeting SDK version 0.9.4 at the moment) were updated to use the latest SDK.

I’ve been able to update the source code to use the 1.0.3 APIs, but although the application compiles and installs, it just doesn’t work (i.e. onEnteredRegion never fires). Yet it works fine using the 0.9.4 SDK.

Any help on this would be great.

It all works good up to SDK 0.16.0 using the old APIs.

I lost the log, but there was something about

Could not find class ‘android.bluetooth.le.ScanSettings$Builder’

when I was using version 1.0.3

Hi @Pacopag,

I wrote a little introduction for using monitoring technology in a foreground activity:

  1. create an instance of the BeaconManager class,
  2. set a listener for monitoring to this instance,
  3. setup the region you want to monitor,
  4. call the startMonitoring method every time the activity comes to the foreground,
  5. stop the monitoring action when the activity goes to the background,
  6. disconnect from the service when the activity is killed.

[details=Example (Java code):]

public class MyMonitoringActivity {
    private BeaconManager mBeaconManager;
    private BeaconRegion mBeaconRegion;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // 1.
        mBeaconManager = new BeaconManager(this);

        // 2.
        mBeaconManager.setMonitoringListener(new BeaconManager.BeaconMonitoringListener {
            @Override
            public void onEnteredRegion(BeaconRegion region, List<Beacon> list) {
                // Handle the event here.
            }

            @Override
            public void onExitedRegion(BeaconRegion region) {
                // Handle the event here.
            }
        });

        // 3.
        mBeaconRegion = new BeaconRegion(
            mIdentifier,
            mUuid,
            mMajor,
            mMinor);
    }

    @Override
    protected void onResume() {
        super.onResume();

        // 4.
        SystemRequirementsChecker.checkWithDefaultDialogs(this);

        mBeaconManager.connect(new BeaconManager.ServiceReadyCallback() {
            @Override
            public void onServiceReady() {
                mBeaconManager.startMonitoring(mBeaconRegion);
            }
        });
    }

    @Override
    protected void onPause() {
        // 5.
        mBeaconManager.stopMonitoring(mBeaconRegion);
    }

    @Override
    protected void onDestroy() {
        // 6.
        mBeaconManager.disconnect();

        super.onStop();
    }
}
```[/details]----------
[details=Tips:]
* the instance of `BeaconManager` cannot be a **local variable** because you need it in the different methods of your activity.
* you can choose to override only **one of the two** callback methods `onEnteredRegion()` or `onExitedRegion()`,
* you can use the **`Log`** class in the overrided callback methods to verify the event quickly: `Log.i("MyMonitoringActivity", "Region entered!");`
* in the example code, `myIdentifier` is a `String` class instance, `myUuid` a **`UUID`** class instance and `mMajor` and `mMinor` are integers.
* you can easily transform a `String` to a `UUID` with the **`UUID.fromString()`** method.
* The _monitoring_ (like the _ranging_) feature can work on **different regions**:
`Region(myIdentifier, myUuid, myMajor, myMinor)` to range the -unique- beacon with defined UUID/major/minor,
`Region(myIdentifier, myuuid, myMajor, null)` to range all the beacons with defined UUID/major,
`Region(myIdentifier, myuuid, null, null)` to range all the beacons with the defined UUID,
`Region(myIdentifier, null, null, null)` to range all the beacons.
* do not forget to check the **permissions** with the `SystemRequirementsChecker.checkWithDefaultDialogs()` method.
* the manager has to be connected to the Estimote **service** with the `BeaconManager.connect()` method; the first time it will connect, and the other times it will start monitoring directly.
* in this example, we stop the _monitoring_ task on the onPause() method, but it can work in **background** (not the _ranging_!).
* don't forget to **disconnect** the manager from the service when you kill the activity.[/details]----------

Hope it works, please notice me if I did something wrong ;)