简体   繁体   English

您好,我想使用蓝牙 iBeacon 进行检测,但效果不佳。 我该如何解决?

[英]Hello I want to detect using a Bluetooth iBeacon, but it does not work well. How can I solve it?

Hello I want to detect using a Bluetooth iBeacon, but it does not work well.您好,我想使用蓝牙 iBeacon 进行检测,但效果不佳。 How can I solve it?我该如何解决? I am testing by connecting with a real mobile phone, not an emulator.我通过连接真正的手机而不是模拟器进行测试。

2020-06-13 22:42:01.729 26437-26728/com.example.beacon D/BluetoothAdapter: STATE_ON 2020-06-13 22:42:01.729 26437-26728/com.example.beacon D/BluetoothLeScanner: could not find callback wrapper 2020-06-13 22:42:08.353 26437-26728/com.example.beacon D/BluetoothAdapter: STATE_ON 2020-06-13 22:42:08.353 26437-26728/com.example.beacon D/BluetoothLeScanner: could not find callback wrapper 2020-06-13 22:42:01.729 26437-26728/com.example.beacon D/BluetoothAdapter:STATE_ON 2020-06-13 22:42:01.729 26437-26728/com.example.beacon D/BluetoothLeScanner:找不到回调包装器 2020-06-13 22:42:08.353 26437-26728/com.example.beacon D/BluetoothAdapter: STATE_ON 2020-06-13 22:42:08.353 26437-26728/com.example.beacon D/BluetoothLeScanner: 可以找不到回调包装器

Is that it continues to be filmed.是不是还在继续拍。

public class MainActivity extends AppCompatActivity  implements BeaconConsumer {
    protected static final String TAG = "MonitoringActivity";
    private BeaconManager beaconManager;


    PermissionListener permissionlistener = new PermissionListener() {
        @Override
        public void onPermissionGranted() {
            Toast.makeText(MainActivity.this, "Permission Granted", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onPermissionDenied(List<String> deniedPermissions) {
            Toast.makeText(MainActivity.this, "Permission Denied\n" + deniedPermissions.toString(), Toast.LENGTH_SHORT).show();
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        beaconManager = BeaconManager.getInstanceForApplication(this);
        // To detect proprietary beacons, you must add a line like below corresponding to your beacon
        // type.  Do a web search for "setBeaconLayout" to get the proper expression.
        beaconManager.getBeaconParsers().add(new BeaconParser().
                setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
        beaconManager.bind(this);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        beaconManager.unbind(this);
    }
    @Override
    public void onBeaconServiceConnect() {
        beaconManager.removeAllMonitorNotifiers();
        beaconManager.addMonitorNotifier(new MonitorNotifier() {
            @Override
            public void didEnterRegion(Region region) {
                Log.i(TAG, "I just saw an beacon for the first time!");
            }

            @Override
            public void didExitRegion(Region region) {
                Log.i(TAG, "I no longer see an beacon");
            }

            @Override
            public void didDetermineStateForRegion(int state, Region region) {
                Log.i(TAG, "I have just switched from seeing/not seeing beacons: "+state);
            }
        });

        try {
            beaconManager.startMonitoringBeaconsInRegion(new Region("E2C56DB5-DFFB-48D2-B060-D0F5A71096E0", null, null, null));
        } catch (RemoteException e) {    }
    }
}

Make sure you have declared FINE_LOCATION permission in your AndroidManifest.xml and you go through the steps to obtain that permission from the user .确保您已在您的 AndroidManifest.xml 和go 中声明了 FINE_LOCATION 权限,以从用户那里获得该权限

Once you have completed those steps, if you still see these messages, read here: https://stackoverflow.com/a/42821272/1461050完成这些步骤后,如果您仍然看到这些消息,请在此处阅读: https://stackoverflow.com/a/42821272/1461050

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我不太了解矩阵。 有人知道 output 吗? - I don't comprehend matrixes very well. Does anyone know the output? 在 rest 保证框架中,我在一个请求中发送路径参数,但它们也与另一个请求一起发送。 我们如何删除路径参数? - In rest assured framework,I am sending path params in one request but they are being send with another request as well. How can we remove path params? 如何检测照片是否垂直拍摄? (我找到了一种方法,但是没有用) - How can I detect photo is taken vertical or not? (I find a way but it does not work) 您好,我该如何解决片段中的问题 - 将编辑文本转换为字符串 - Hello, how can I solve problem in fragment - get edit text to string 您好,我想创建一个javafx项目,但是它需要数据库吗? - Hello, I want to create a javafx project, but does it need Database? 如何使用 Java API 从 Dialogflow CX 检测意图并将代理响应作为音频和文本获取? - How can I detect intent and get the agent response as audio as well as text from Dialogflow CX using the Java API? 我怎样才能使这个timer()正常工作? - How can I make this timer() work as I want? 如何解决此扫描仪问题? 我希望这四个操作有效,但是每当我键入它并单击Enter时,它都将不起作用 - How do I solve this scanner issue? I want the four actions to work but whenever I type it in and click enter it doesn't work 我在JTable中加载了一个文本文件,我希望在JTable中进行的更改也要在文本文件中进行,我该怎么做? - I have a text file loaded in a JTable, i want that the changes i make in the JTable to be made in in the text file as well, how can i do that? 我如何获得一个简单的Hello World应用程序以在Spring Boot中工作 - How can I to get a simple Hello World App to work in Spring Boot
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM