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

时间:2018-11-24 14:07:01

标签: android restart beacon altbeacon

我的应用程序中存在一些问题。在禁用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

2 个答案:

答案 0 :(得分:0)

一旦您开始进行范围监视或监控,该库将尝试使其即使在后台以及在应用终止后也继续运行。该库之所以这样做,是因为当内存不足或用户已在前台使用该应用程序时,操作系统或用户通常会终止该应用程序。

自动重启是通过多种技术完成的,包括5分钟的AlarmManager计时器,START_STICKY服务标志(Android 4.3-7.x)和15分钟的JobService(Android 8+)。这样一来,便可以在后台扫描信标以在发现时自动启动应用程序逻辑,并且默认情况下,这样做会占用最少的系统资源。

由于System.exit(0)有效地使您的应用程序崩溃,从而启用了库扫描,因此该应用程序正在自动重启。

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

答案 1 :(得分:0)

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

from django.conf.urls import url
from my_awesome_app.views import MyLoginView

urlpatterns = [
    url(
        regex=r'^account/login/$',
        view=MyLoginView.as_view(),
        name='login',
    ),
    include(...),
]

当我启用监视时,将其设置回true。

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

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

所以我的退出函数如下:

mBeaconManager.setBackgroundMode(true);