AltBeacon应用程序在几分钟后重新启动

问题描述 投票:2回答:2

我的应用程序中存在一些问题。我禁用了regionBootstrap并通过System.exit(0)关闭应用程序后,我的应用程序在几分钟后(通常为3-4分钟)重启自己。

这是我每次重新启动应用程序时发现的Logcat行:

2018-11-24 14:54:34.883 897-1339/? V/AlarmManager: Triggering alarm #1: 2 when =969099760 package =walkenrollment.com.acc operation =*walarm*:walkenrollment.com.acc/org.altbeacon.beacon.startup.StartupBroadcastReceiver flags =0x0
2018-11-24 14:54:34.941 897-1136/? I/ActivityManager: Start proc 11637:walkenrollment.com.acc/u0a181 for broadcast walkenrollment.com.acc/org.altbeacon.beacon.startup.StartupBroadcastReceiver
2018-11-24 14:54:35.037 897-11631/? D/OnePlusSmartBoostManager: writeHotCount walkenrollment.com.acc, pid=11637
2018-11-24 14:54:35.107 11637-11637/walkenrollment.com.acc I/ollment.com.ac: The ClassLoaderContext is a special shared library.
2018-11-24 14:54:35.210 11637-11637/walkenrollment.com.acc W/ollment.com.ac: JIT profile information will not be recorded: profile file does not exits.
2018-11-24 14:54:35.211 11637-11637/walkenrollment.com.acc I/chatty: uid=10181(walkenrollment.com.acc) identical 10 lines
2018-11-24 14:54:35.212 11637-11637/walkenrollment.com.acc W/ollment.com.ac: JIT profile information will not be recorded: profile file does not exits.
2018-11-24 14:54:35.219 11637-11637/walkenrollment.com.acc I/Perf: Connecting to perf service.
2018-11-24 14:54:35.207 11637-11637/walkenrollment.com.acc W/ollment.com.acc: type=1400 audit(0.0:2234740): avc: denied { read } for name="u:object_r:vendor_iop_prop:s0" dev="tmpfs" ino=17676 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:vendor_iop_prop:s0 tclass=file permissive=0
2018-11-24 14:54:35.207 11637-11637/walkenrollment.com.acc W/ollment.com.acc: type=1400 audit(0.0:2234741): avc: denied { read } for name="u:object_r:vendor_iop_prop:s0" dev="tmpfs" ino=17676 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:vendor_iop_prop:s0 tclass=file permissive=0
2018-11-24 14:54:35.222 11637-11637/walkenrollment.com.acc E/libc: Access denied finding property "vendor.perf.iop_v3.enable"
2018-11-24 14:54:35.222 11637-11637/walkenrollment.com.acc E/libc: Access denied finding property "vendor.perf.iop_v3.enable.debug"
2018-11-24 14:54:35.233 11637-11637/walkenrollment.com.acc I/InstantRun: starting instant run server: is main process
2018-11-24 14:54:35.235 11637-11637/walkenrollment.com.acc V/Font: Change font:2
2018-11-24 14:54:35.242 11637-11637/walkenrollment.com.acc I/BeaconManager: BeaconManager started up on pid 11637 named 'walkenrollment.com.acc' for application package 'walkenrollment.com.acc'.  isMainProcess=true
2018-11-24 14:54:35.245 11637-11637/walkenrollment.com.acc D/BeaconParser:          Parsing beacon layout: m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25
2018-11-24 14:54:35.246 11637-11637/walkenrollment.com.acc D/BeaconParser: Parsing beacon layout: m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24
2018-11-24 14:54:35.247 11637-11637/walkenrollment.com.acc D/BeaconParser: Parsing beacon layout: x,s:0-1=feaa,m:2-2=20,d:3-3,d:4-5,d:6-7,d:8-11,d:12-15

可能是什么原因? OnePlusSmartBoostManager是问题的根源吗?如何避免我的应用程序以这种方式重新启动?

这些是重启前几分钟来自logcat的其他行:

2018-11-24 14:48:40.989 897-2922/? I/ActivityManager: Process walkenrollment.com.acc (pid 11211) has died: fore RCVR
2018-11-24 14:48:40.991 897-912/? I/WindowManager: WIN DEATH: Window{b786f1c u0 walkenrollment.com.acc/walkenrollment.com.acc.MainActivity}
2018-11-24 14:48:40.991 897-912/? W/InputDispatcher: Attempted to unregister already unregistered input channel 'b786f1c walkenrollment.com.acc/walkenrollment.com.acc.MainActivity (server)'
2018-11-24 14:51:30.213 897-1132/? D/RestartProcessManager: updateSelf :  walkenrollment.com.acc, size : 30
2018-11-24 14:51:30.214 897-1132/? D/RestartProcessManager: walkenrollment.com.acc got score 0.45182973997082543 in DayDuration for duration : 16565
2018-11-24 14:51:30.214 897-1132/? D/RestartProcessManager: walkenrollment.com.acc got score 100.0 in DayLRU for LRU diff : 49716982
2018-11-24 14:51:30.214 897-1132/? D/RestartProcessManager: walkenrollment.com.acc got score 33.33333333333333 in DayLaunchTimes for launch times : 5
2018-11-24 14:51:30.215 897-1132/? D/RestartProcessManager: walkenrollment.com.acc : X : 11871.538678708397, Y : 3274.222404673991, Z : 23827.1189741647
android restart beacon altbeacon
2个回答
0
投票

一旦你开始测距或监控,图书馆将尝试即使在后台甚至在应用程序终止后仍然保持运行。该库可以做到这一点,因为当内存不足或用户在前台使用它时,操作系统或用户通常会终止应用程序。

自动重启是通过几种技术完成的,包括5分钟的AlarmManager计时器和START_STICKY服务标志(Android 4.3-7.x)和15分钟的JobService(Android 8+)。这允许在后台扫描信标以在发现时自动启动应用程序逻辑,并且默认情况下使用最少的系统资源执行此操作。

该应用程序是自动重启,因为System.exit(0)有效地崩溃了您的应用程序,启用了库扫描。

如果您不希望发生这种情况,则必须先干净地关闭扫描。停止测距和/或监视然后从BeaconManager解除绑定(如果绑定它)或在RegionBootstrap上调用disable()(如果您使用它来启动扫描)。


0
投票

我通过在禁用监视功能中添加以下内容解决了这个问题。

// Disables alarm manager
mBeaconManager.setBackgroundMode(false);

if (mRegionBootstrap != null) {
    mRegionBootstrap.disable();
    mRegionBootstrap = null;
}

当我启用监控时,我将其设置为true。

mBeaconManager.setBackgroundMode(true);

所以我的退出功能如下:

// Disables monitoring
mBeaconScannerServiceManager.disableMonitoring();

// Closes UI
finishAffinity();

// Destroys app completely after it had time to turn off services correctly
mContainerView.postDelayed(() -> System.exit(0), 2000);
© www.soinside.com 2019 - 2024. All rights reserved.