使用 Gimbal sdk 编程我的 android 应用程序未检测到 gimbal beacon

Programming my android application with Gimbal sdk doesn't detect the gimbal beacon

我正在尝试创建一个 android 应用程序来使用 Gimbal sdk 检测基于 Gimbal 的信标,但我的应用程序无法检测到信标。但是如果我尝试使用 BluetoothGATT,我可以检测到信标。以下是我的代码中监听信标事件的部分。 API 密钥验证成功但仍然无法显示接近度。

public class MainActivity extends Activity {

    private PlaceManager placeManager;
    private PlaceEventListener placeEventListener;
    private BeaconEventListener beaconEventListener;
    private BeaconManager beaconManager;
    private String TAG = "beacon";

    public ArrayAdapter<String> listAdapter;
    public ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        Gimbal.setApiKey(getApplication(),
                "MY API KEY ");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        initView();

        monitorPlace();

        listenBeacon();



        CommunicationManager.getInstance().startReceivingCommunications();

    }

    private void listenBeacon() {
        BeaconEventListener beaconEventListener = getBeaconEventListener();
        BeaconManager beaconManager = new BeaconManager();
        beaconManager.addListener(beaconEventListener);
        beaconManager.startListening();
    }

    private void monitorPlace() {
        placeEventListener = getPlaceEventListener();

        // placeManager = PlaceManager.getInstance();
        // placeManager.addListener(placeEventListener);
        placeManager = PlaceManager.getInstance();
        placeManager.addListener(placeEventListener);
        placeManager.startMonitoring();
    }

    private void initView() {
        GimbalLogConfig.enableUncaughtExceptionLogging();
        listAdapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_expandable_list_item_1);

        listView = (ListView) findViewById(R.id.list);
        listView.setAdapter(listAdapter);
        listAdapter.add(" Gimbal API Key got Set Successfuly");
        listAdapter.notifyDataSetChanged();
        GimbalDebugger.enableBeaconSightingsLogging();
    }

    private BeaconEventListener getBeaconEventListener() {
        Log.i(TAG, "BeaconEventListener started sucessfully...");
        BeaconEventListener beaconSightingListener = new BeaconEventListener() {
            @Override
            public void onBeaconSighting(BeaconSighting beaconSighting) {

                super.onBeaconSighting(beaconSighting);


                listAdapter.add(String.format("Name of  Beacon is %s",
                        beaconSighting.getBeacon().getName()));
                listAdapter.add(String.format("UUID is %s", beaconSighting
                        .getBeacon().getUuid()));
                listAdapter.add(String.format("RSSI is %s",
                        beaconSighting.getRSSI()));
                listAdapter.add(String.format("Battery Level is %s",
                        beaconSighting.getBeacon().getBatteryLevel()));
                listAdapter.add(String.format("Temprature data is %s",
                        beaconSighting.getBeacon().getTemperature()));

            }
        };




    }

    private PlaceEventListener getPlaceEventListener() {

        PlaceEventListener obj = new PlaceEventListener() {
            @Override
            public void onBeaconSighting(BeaconSighting sight, List<Visit> visit) {


                super.onBeaconSighting(sight, visit);

                listAdapter.add(String.format("Beacon Found: %s",
                        sight.getBeacon()));
                listAdapter.add(String.format("Name of Beacon is %s", sight
                        .getBeacon().getName()));
                listAdapter.add(String.format("Identifier  is %s", sight
                        .getBeacon().getIdentifier()));
                listAdapter.add(String.format("RSSI is %s", sight.getRSSI()));
                listAdapter.add(String.format("UUID is %s", sight.getBeacon()
                        .getUuid()));
                listAdapter.add(String.format("Temprature is%s", sight
                        .getBeacon().getTemperature()));
                listAdapter.add(String.format("BatteryLevel is %s", sight
                        .getBeacon().getBatteryLevel()));
                listAdapter.add(String.format("Icon URL is %s", sight
                        .getBeacon().getIconURL()));

                listAdapter.add(String.format("Start Visit for %s", visit
                        .iterator().toString()));

            }

            // @Override
            public void onVisitStart(Visit visit) {
                 super.onVisitStart(visit);

                listAdapter.add(String.format("Start Visit for %s", visit
                        .getPlace().getName()));

                Toast.makeText(getApplicationContext(),
                        visit.getPlace().getName(), Toast.LENGTH_SHORT).show();
                listAdapter.notifyDataSetChanged();

            }

            @Override
            public void onVisitEnd(Visit visit) {
                // TODO Auto-generated method stub
                super.onVisitEnd(visit);

                listAdapter.add(String.format("End Visit for %s", visit
                        .getPlace().getName()));
                listAdapter.notifyDataSetChanged();

            }

        };


        return obj;
    }

}

在云台管理器中添加信标详细信息确实解决了问题。 从 Gimbal 团队得到了下面的代码

It is mandatory to add the beacons in Gimbal Manager for detecting beacons