Why is the beaconmanager just finding a beacon?

37 views Asked by At

My problem is that the beacon manager just finds a beacon.

My code is below;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
//location permission
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, 1234);
    }
    button = (Button) findViewById(R.id.b1);
  //button onClick
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mBeaconManager = BeaconManager.getInstanceForApplication(getApplicationContext());
            mBeaconManager.getBeaconParsers().add(new BeaconParser().
            setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT));
            mBeaconManager.getBeaconParsers().add(new BeaconParser().
                    setBeaconLayout(BeaconParser.EDDYSTONE_TLM_LAYOUT));
            mBeaconManager.getBeaconParsers().add(new BeaconParser().
                    setBeaconLayout(BeaconParser.EDDYSTONE_URL_LAYOUT));
            mBeaconManager.bind(MainActivity.this);
        }
    });
}
@Override
public void onBeaconServiceConnect() {
    ArrayList<Identifier> identifiers = new ArrayList<>();
    identifiers.add(null);
    Region region = new Region("all-beacons-region", identifiers);
    try {
        mBeaconManager.startRangingBeaconsInRegion(region);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
    mBeaconManager.addRangeNotifier(this);
}

//display beacon size @Override public void didRangeBeaconsInRegion(Collection beacons, Region region) { Log.i(TAG,"" + beacons.size()); } }

The result beacon.size 1. But there are three beacons. What should I do to find more than one beacon? I'll be happy if you can help me.

0

There are 0 answers