IBeacon收到警告隐式意图在MonitorNotifier的回调上不安全 [英] IBeacon getting warning Implcit intents are not safe on callback of MonitorNotifier

查看:92
本文介绍了IBeacon收到警告隐式意图在MonitorNotifier的回调上不安全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android 4.4,并且在发现具有指定区域的信标时在监视的回调中收到警告消息。

I am using Android 4.4 and getting a warning message in the callback of Monitoring when a beacon with specified region is found.

我用于监视的代码是

@Override
public void onIBeaconServiceConnect() {

    iBeaconManager.setMonitorNotifier(new MonitorNotifier() {
        @Override
        public void didEnterRegion(Region region) {
          Log.e("didEnterRegion","I just saw an iBeacon for the first time!");       
        }

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

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

            if(state == MonitorNotifier.INSIDE){
                try {
                    //Start Ranging in the Region.
                    iBeaconManager.startRangingBeaconsInRegion(region);
                } catch (RemoteException e) { 
                    System.out.println(e);
                }

            }
            else if(state == MonitorNotifier.OUTSIDE){
                try {
                    //Stop Ranging in the Region.
                    iBeaconManager.stopRangingBeaconsInRegion(region);
                } catch (RemoteException e) { 
                    System.out.println(e);
                }

            }
        }
        });

        try {
            //Start Monitoring in the Region.
            iBeaconManager.startMonitoringBeaconsInRegion(region);
        } catch (RemoteException e) { 
            System.out.println(e);
        }

而我在logcat中发现的警告消息是

and the warning message I found in logcat is

04-19 14:32:08.156: D/BluetoothAdapter(10564): startLeScan(): null 
04-19 14:32:08.166: D/BluetoothAdapter(10564): onClientRegistered() - status=0 clientIf=5 
04-19 14:32:08.176: D/IBeaconService(10564): Scan started 
04-19 14:32:08.186: D/IBeaconManager(10564): Got a ranging callback 
04-19 14:32:08.186: D/IBeaconManager(10564): Got a ranging callback with 0 iBeacons 
04-19 14:32:08.186: D/IBeaconManager(10564): Calling ranging notifier on :com.example.ranging.BackgroundRanging$4@4226f1e8 
04-19 14:32:08.787: D/BluetoothAdapter(10564): onScanResult() - Device=4A:92:06:A9:FA:87 RSSI=-52 
04-19 14:32:08.787: D/IBeaconService(10564): got record 
04-19 14:32:08.797: D/IBeacon(10564): calculating accuracy based on rssi of -52.0 
04-19 14:32:08.797: D/IBeaconService(10564): iBeacon detected :128f4e13-01ef-4618-bffa-50fed67f24aa 1001 3003 accuracy: 0.47659904336004005 proximity: 1 
04-19 14:32:08.797: D/Callback(10564): attempting callback via intent: com.example.service.DID_MONITORING 
04-19 14:32:08.807: W/ContextImpl(10564): Implicit intents with startService are not safe: Intent { act=com.example.service.DID_MONITORING (has extras) } android.content.ContextWrapper.startService:494 com.radiusnetworks.ibeacon.service.Callback.call:85 com.radiusnetworks.ibeacon.service.IBeaconService.processIBeaconFromScan:438  
04-19 14:32:08.817: D/IBeaconService(10564): looking for ranging region matches for this ibeacon 
04-19 14:32:08.817: D/IBeaconService(10564): matches ranging region: proximityUuid: 128f4e13-01ef-4618-bffa-50fed67f24aa major: null minor:null 
04-19 14:32:09.257: D/IBeaconService(10564): Done with scan cycle 
04-19 14:32:09.257: D/IBeaconService(10564): Calling ranging callback with 1 iBeacons 
04-19 14:32:09.257: D/Callback(10564): attempting callback via messenger 
04-19 14:32:09.257: D/IBeaconService(10564): Restarting scan.  Unique beacons seen last cycle: 1 
04-19 14:32:09.257: D/BluetoothAdapter(10564): stopLeScan() 


推荐答案

此警告出现在Android iBeacon库的版本为0.7或更旧的版本中。最新版本是0.7.6,不会有此警告。简单的解决方案是在此处升级到最新版本的库。

This warning appears with outdated versions of the Android iBeacon Library, 0.7 or prior. The latest version is 0.7.6 and will not have this warning. The easy solution is to simply upgrade to the latest version of the library available here.

警告与iBeacon数据在库的后台服务和您的应用之间传递的方式有关。该库的早期版本使用隐式意图来传递此信息,如果两个应用同时在使用该库的电话上使用,则从理论上讲,这可能会导致iBeacon数据传给错误的应用。出于开发目的,这并不重要,但是如果在生产应用程序中使用最新的库版本,则应使用该库的最新版本。

The warning has to do with the way that iBeacon data are passed between the library's background service and your app. Early versions of the library used an "implicit intent" to pass this information, which could theoretically cause iBeacon data to the wrong app if two apps were on the phone using the library simultaneously. For development purposes, it doesn't really matter, but you should use the latest library version if using it in a production app.

这篇关于IBeacon收到警告隐式意图在MonitorNotifier的回调上不安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆