gpt4 book ai didi

android - 使用 Radius Networks Pro iBeacon SDK 的后台 BLE 触发器

转载 作者:行者123 更新时间:2023-11-30 02:52:29 25 4
gpt4 key购买 nike

我正在运行 Android 4.3 的三星 Galaxy Tab 2 上使用专业版 Radius Networks iBeacon SDK 进行开发。该应用程序已经成功使用非专业版 0.7 一个月了,但我想要后台事件,所以我已经转到专业版 1.0。 AndroidProximityLibrary项目是Eclipse中的项目依赖,ProximityKit.properties文件在src/

以下代码是我的应用程序子类,如 documentation 中所述。该应用程序具有 BLUETOOTH 和 BLUETOOTH_ADMIN 权限。从 LogCat 输出中可以看出,didDetermineStateForRegion() 方法在进入休眠状态后未按预期调用。必须改变什么才能在后台发生某些事情?

我看到了一个名为 iBeacon background scanning PRO feature of RadiusNetworks library? 的类似问题,但问题似乎是调用 IBeaconManager.unbind() 导致操作系统清理服务。我的代码从不调用 IBeaconManager.unbind(),只调用 IBeaconManager.bind()

public class ExampleApp extends Application implements BootstrapNotifier, IBeaconConsumer {

private static final String LOG_TAG = ExampleApp.class.getName();
private RegionBootstrap regionBootstrap;
private IBeaconManager iBeacon;
private Region region;

public ExampleApp() {
String uuid = "EBEFD083-70A2-47C8-9837-E7B5634DF520";
region = new Region("com.example.ble", uuid, null, null);
}

@Override
public void onCreate() {
super.onCreate();
iBeacon = IBeaconManager.getInstanceForApplication(this);
iBeacon.setBackgroundBetweenScanPeriod(10000);
iBeacon.setBackgroundScanPeriod(3000);
iBeacon.bind(this);
regionBootstrap = new RegionBootstrap(this, region);
}

@Override
public void onIBeaconServiceConnect() {
Log.d(LOG_TAG + ".onIBeaconServiceConnect", "connected to iBeacon service");
try {
iBeacon.startRangingBeaconsInRegion(region);
} catch (RemoteException e) {
String msg = "caught exception while enabling beacon ranging";
Log.e(LOG_TAG + ".onIBeaconServiceConnect", msg, e);
}
}

@Override
public void didEnterRegion(Region region) {
Log.d(LOG_TAG + ".didEnterRegion", "YEAH ENTERED");
}

@Override
public void didDetermineStateForRegion(int state, Region region) {
Log.d(LOG_TAG + ".didDetermineStateForRegion", "YEAH STATE");
Intent intent = new Intent(this, LaunchActivity.class);
startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}

@Override
public void didExitRegion(Region region) {
Log.d(LOG_TAG + ".didExitRegion", "YEAH EXITED");
}

}

我在信标范围外运行应用程序,然后走进范围内。 30 秒后没有任何反应,所以我按下电源按钮,但仍然没有任何反应。我插上电话,从亚行那里得到了踪迹。

LogCat 在 sleep (Home 然后 Power)和 30 秒后唤醒(Power)之间处于 INFO 级别

05-28 14:05:23.456: I/PowerManagerService(2392): [ps] Screen__Off(0) :  goToSleepFromNative:  (uid: 1000 pid: 2392)
05-28 14:05:23.456: I/PowerManagerService(2392): Going to sleep by user request...
05-28 14:05:23.471: W/KeyguardViewMediator(2392): wakeUpIfNeeded() mMaybeShow=true mRequestedWakeUp=false mShowing=false
05-28 14:05:23.516: E/SEC PowerHAL(2392): sysfs_write : Error opening /sys/class/input/input11/enabled: No such file or directory
05-28 14:05:23.516: E/SEC PowerHAL(2392): sysfs_write : Error opening /sys/class/input/input1/enabled: No such file or directory
05-28 14:05:23.516: E/SEC PowerHAL(2392): sysfs_write : Error opening /sys/class/input/input10/enabled: No such file or directory
05-28 14:05:23.521: I/libsuspend(2392): !@[s] autosuspend_earlysuspend_enable : 40
05-28 14:05:23.521: I/libsuspend(2392): !@[s] wait_for_fb_sleep : 40 (1, 0) -
05-28 14:05:23.521: I/libsuspend(2392): !@[s] autosuspend_earlysuspend_enable done : 40
05-28 14:05:23.521: I/libsuspend(2392): !@[s] wait_for_fb_wake : 40 (0, 0) +
05-28 14:05:23.521: I/PowerManagerService(2392): [PWL] Off : 0s ago
05-28 14:05:23.521: I/PowerManagerService(2392): [PWL] PowerManagerService.WakeLocks: ref count=1
05-28 14:05:23.521: I/PowerManagerService(2392): [PWL] PowerManagerService.Broadcasts: ref count=1
05-28 14:05:23.521: I/PowerManagerService(2392): [PWL] mWakeLockSummary : 0x1
05-28 14:05:23.521: I/PowerManagerService(2392): [PWL] PARTIAL_WAKE_LOCK 'ActivityManager-Sleep' (uid=1000, pid=2392, ws=null) (elapsedTime=42)
05-28 14:05:23.526: I/CAE(2392): onReceive(CaPowerManager.java:142) - AP_SLEEP
05-28 14:05:23.531: I/CAE(2392): sendCmdToSensorHub(SensorHubCommManager.java:146) - -76, 13, -46, 0,
05-28 14:05:23.561: I/CAE(2392): parse(SensorHubParserProvider.java:136) - buffer size = 3
05-28 14:05:23.561: I/CAE(2392): parse(SensorHubParserProvider.java:147) - 2, 1, -46,
05-28 14:05:23.591: I/AudioHardwareTinyALSA(1989): setParameters(screen_state=off)
05-28 14:05:23.591: I/audio_wfd_hw(1989): adev_set_parameters() screen_state=off
05-28 14:05:23.616: I/NfcService(2909): # NativeNfcBrcmPowerMode; setPowerMode(android.intent.action.SCREEN_OFF)
05-28 14:05:23.621: E/NfcService(2909): callback == null
05-28 14:05:23.691: I/AutoBackupUtil(9627): checkAutoBackupCondition returns : false
05-28 14:05:23.691: I/AutoBackupUtil(9627): bChargerConnected : true
05-28 14:05:23.691: I/AutoBackupUtil(9627): bWifiConnected : false
05-28 14:05:23.691: I/AutoBackupUtil(9627): bScreenOn : false
05-28 14:05:24.871: I/SurfaceFlinger(1986): id=996 Removed Uoast (5/6)
05-28 14:05:24.871: I/SurfaceFlinger(1986): id=996 Removed Uoast (-2/6)
05-28 14:05:28.526: I/PowerManagerService(2392): [PWL] Off : 5s ago
05-28 14:05:38.541: I/PowerManagerService(2392): [PWL] Off : 15s ago
05-28 14:05:51.251: E/Watchdog(2392): !@Sync 8274
05-28 14:05:53.556: I/PowerManagerService(2392): [PWL] Off : 30s ago
05-28 14:05:55.986: E/BatteryService(2392): Could not open /efs/FactoryApp/batt_cable_count
05-28 14:05:56.081: E/Sensors(2392): Light old sensor_state 0, new sensor_state : 64 en : 1
05-28 14:05:56.096: I/SensorService(2392): info.selectDelay() ns=200000000
05-28 14:05:56.101: I/PowerManagerService(2392): [ps] Screen__On(wake lock) : wl: charger plug
05-28 14:05:56.101: I/PowerManagerService(2392): Waking up from sleep...
05-28 14:05:56.126: I/libsuspend(2392): !@[s] autosuspend_earlysuspend_disable : 41
05-28 14:05:56.151: I/KeyguardBackgroundView(2392): *** KeyguardEffectView getInstance ***
05-28 14:05:56.151: I/WindowManager(2392): No lock screen!
05-28 14:05:56.196: I/NfcService(2909): # NativeNfcBrcmPowerMode; setPowerMode(android.intent.action.USER_PRESENT)
05-28 14:05:56.266: E/videowall-TranscodeReceiver(10819): broadcastMSG : android.intent.action.ACTION_POWER_CONNECTED
05-28 14:05:56.276: I/EntropyMixer(2392): Writing entropy...
05-28 14:05:56.281: E/Sensors(2392): Light old sensor_state 64, new sensor_state : 0 en : 0
05-28 14:05:56.326: I/CAE(2392): onReceive(CaPowerManager.java:150) - POWER_CONNECTED
05-28 14:05:56.326: I/CAE(2392): sendCmdToSensorHub(SensorHubCommManager.java:146) - -76, 13, -42, 0,
05-28 14:05:56.426: E/Launcher(2928): Error finding setting, default accessibility to not found: accessibility_enabled
05-28 14:05:56.536: I/SSRMv2:Monitor(2392): fileWriteInt : /sys/class/power_supply/battery/siop_level value : 100
05-28 14:05:56.546: E/Sensors(2392): Light old sensor_state 0, new sensor_state : 64 en : 1
05-28 14:05:56.556: I/SensorService(2392): info.selectDelay() ns=200000000
05-28 14:05:56.556: E/Sensors(2392): Light old sensor_state 64, new sensor_state : 0 en : 0
05-28 14:05:56.556: E/MotionRecognitionService(2392): mReceiver.onReceive : ACTION_USER_PRESENT :: UNLOCK SCREEN
05-28 14:05:56.571: E/BatteryService(2392): Could not open /efs/FactoryApp/batt_cable_count
05-28 14:05:56.576: I/libsuspend(2392): !@[s] wait_for_fb_wake : 41 (1, 0) -
05-28 14:05:56.576: I/libsuspend(2392): !@[s] wait_for_fb_sleep : 41 (0, 0) +
05-28 14:05:56.576: I/libsuspend(2392): !@[s] autosuspend_earlysuspend_disable done : 41
05-28 14:05:56.576: E/SecTVOutService(1986): virtual void android::SecTVOutService::setHdmiStatus(uint32_t)::mSecHdmi.connect() fail
05-28 14:05:56.576: E/SEC PowerHAL(2392): sysfs_write : Error opening /sys/class/input/input11/enabled: No such file or directory
05-28 14:05:56.576: E/SEC PowerHAL(2392): sysfs_write : Error opening /sys/class/input/input1/enabled: No such file or directory
05-28 14:05:56.576: E/SEC PowerHAL(2392): sysfs_write : Error opening /sys/class/input/input10/enabled: No such file or directory
05-28 14:05:56.616: I/CAE(2392): onReceive(CaPowerManager.java:146) - AP_WAKEUP
05-28 14:05:56.616: I/CAE(2392): sendCmdToSensorHub(SensorHubCommManager.java:146) - -76, 13, -47, 0,
05-28 14:05:56.681: I/AudioHardwareTinyALSA(1989): setParameters(screen_state=on)
05-28 14:05:56.681: I/audio_wfd_hw(1989): adev_set_parameters() screen_state=on
05-28 14:05:56.796: E/SELinux(11287): Function: selinux_android_load_priority [0], There is no sepolicy file
05-28 14:05:56.796: E/SELinux(11287):
05-28 14:05:56.801: E/SELinux(11287): Function: selinux_android_load_priority , loading version is VE=SEPF_GT-N7105_4.3_0021
05-28 14:05:56.801: E/SELinux(11287):
05-28 14:05:56.801: E/SELinux(11287):
05-28 14:05:56.801: E/SELinux(11287): selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
05-28 14:05:56.821: I/NfcService(2909): NFC: When Screen On, S View Cover also Open!!
05-28 14:05:56.821: I/NfcService(2909): # NativeNfcBrcmPowerMode; setPowerMode(android.intent.action.SCREEN_ON)
05-28 14:05:56.841: I/CAE(2392): parse(SensorHubParserProvider.java:136) - buffer size = 3
05-28 14:05:56.841: I/CAE(2392): parse(SensorHubParserProvider.java:147) - 2, 1, -47,
05-28 14:05:56.871: I/ActivityManager(2392): Killing proc 11287:com.sec.android.SimpleWidget/u0a10145: force stop com.sec.android.SimpleWidget
05-28 14:05:56.886: W/ActivityManager(2392): Permission denied: checkComponentPermission() owningUid=10029

最佳答案

当使用 RegionBootstrap 时,您不需要调用 iBeacon.bind(this); 也不需要 onIBeaconServiceConnect() 的实现>。这是因为这些任务由 RegionBootstrap 类在内部处理。

要解决此问题,请尝试取消对 iBeacon.bind(this);

的手动调用

关于android - 使用 Radius Networks Pro iBeacon SDK 的后台 BLE 触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23904130/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com