MMJ MMJ - 10 months ago 68
Android Question

Error code 2 in beacon transmitter for Android Beacon library

I want to send a BLE advertisement using Android beacon library. Below is the code I am using for it.

package com.example.beacon_emitter;

import java.util.Arrays;

import org.altbeacon.beacon.Beacon;
import org.altbeacon.beacon.BeaconParser;
import org.altbeacon.beacon.BeaconTransmitter;

import android.bluetooth.le.AdvertiseCallback;
import android.bluetooth.le.AdvertiseSettings;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

public class MainActivity extends Activity {

protected void onCreate(Bundle savedInstanceState) {

Beacon beacon = new Beacon.Builder()
.setDataFields(Arrays.asList(new Long[] {0l}))
BeaconParser beaconParser = new BeaconParser()
BeaconTransmitter beaconTransmitter = new BeaconTransmitter(getApplicationContext(), beaconParser);
beaconTransmitter.startAdvertising(beacon,new AdvertiseCallback() {
public void onStartFailure(int errorCode) {
Log.e("beacon", "Advertisement start failed with code: "+errorCode);

public void onStartSuccess(AdvertiseSettings settingsInEffect) {
Log.i("beacon", "Advertisement start succeeded.");

int result = BeaconTransmitter.checkTransmissionSupported(getApplicationContext());
Toast.makeText(this, "Device info " + result, Toast.LENGTH_LONG).show();


public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(, menu);
return true;

public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == {
return true;
return super.onOptionsItemSelected(item);

It always gives me an errorcode 2, ADVERTISE_FAILED_TOO_MANY_ADVERTISERS. But the strange thing is when I checked the toast message it says the my device is supported the beacon transmission. I am confused.

Please help!

Thanks in Advance.

Answer Source

A few tips:

  1. The BeaconTransmitter.checkTransmissionSupported() method only checks to see if the device has Bluetooth LE and that the operating system will give you a BluetoothAdvertiser.

  2. To see if somebody else has been successful with getting your device to transmit, check to see if it is on this list:

  3. The ADVERTISE_FAILED_TOO_MANY_ADVERTISERS response can indicate that another app is advertising a beacon, and all the advertisement slots are used. Make sure that you don't have any other apps advertising in the background. Reboot or uninstall other apps that might be doing this if necessary.

  4. Try the Locate Beacon app which is based on this same library, and see if it can advertise a beacon successfully. This will eliminate any possible problem with your code.

EDIT: Based on the comments below, it is reasonable to conclude that the firmware for the Intrynsyc eval kit does not properly implement the interface between Android and the Bluetooth chip. Otherwise it would either report that advertising is not available or it would not return an error message when starting advertising. The appropriate next step would be to open an issue with Intrynsyc and report these findings.