此行为不是“规则”,有时服务运行没有问题并保持活动状态.
这是我的表现:
<uses-sdk androID:minSdkVersion="17" androID:targetSdkVersion="19" /><uses-permission androID:name="androID.permission.BLUetoOTH"/><uses-permission androID:name="androID.permission.BLUetoOTH_@R_502_5976@"/><uses-permission androID:name="androID.permission.INTERNET" /><uses-permission androID:name="androID.permission.READ_PHONE_STATE" /><uses-permission androID:name="androID.permission.RECEIVE_BOOT_COMPLETED" /><application androID:allowBackup="true" androID:icon="@drawable/my_drawable" androID:label="MyApp" androID:theme="@androID:style/theme.Holo" androID:name="BeaconReferenceApplication"> <activity androID:name="org.altbeacon.beaconreference.MonitoringActivity" androID:theme="@androID:style/theme.Holo" androID:label="MyApp" > <intent-filter> <action androID:name="androID.intent.action.MAIN" /> <category androID:name="androID.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity androID:name="org.altbeacon.beaconreference.RangingActivity" androID:theme="@androID:style/theme.Holo" androID:label="MyApp" > <intent-filter> </intent-filter> </activity>
测试我正在使用三星galaxy tab3(AndroID 4.4.2)和三星galaxy tab4(AndroID 4.4.2)
我试图检查logcat消息,这些行可能可以解释一些东西.
E/BeaconManager( 4802): Cannot contact service to set scan periods
D/BeaconManager( 4802): This consumer is not bound. binding:
org.altbeacon.beaconreference.BeaconReferenceApplication@42320918D/BeaconManager( 4802): consumer count is Now:1
V/ApplicationPolicy( 2365): isApplicationStateBlocked userID 0 pkgname
org.altbeacon.beaconreferenceD/CustomFrequencyManagerService( 2365): acquireDVFSLockLocked : type :
DVFS_MIN_liMIT frequency : 1400000 uID : 1000 pID : 2365 pkgname :
ACTIVITY_RESUME_BOOSTER@5W/ActivityManager( 2365): mDVFSHelper.acquire()
D/Phonestatusbar( 2551): setTransGradationMode=false,
mtransparentMode=false,mSemitransparentMode=false,
mMultiWindowMode=falseW/ResourceType( 2365): No kNown package when getting value for
resource number 0x7f020000D/StatusbarManagerService( 2365): tr p:2365,o:f
W/WindowManager( 2365): Token{432ad010 ActivityRecord{432ace98 u0
org.altbeacon.beaconreference/.MonitoringActivity t3}} Failed creating
starting windowW/WindowManager( 2365):
androID.content.res.Resources$NotFoundException: Resource ID #0x7f020000W/WindowManager( 2365): at
androID.content.res.Resources.getValue(Resources.java:2354)W/WindowManager( 2365): at
androID.content.res.Resources.getDrawable(Resources.java:1919)W/WindowManager( 2365): at
com.androID.internal.Widget.ActionbarVIEw.setIcon(ActionbarVIEw.java:1037)W/WindowManager( 2365): at
com.androID.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3478)W/WindowManager( 2365): at
com.androID.internal.policy.impl.PhoneWindow.getDecorVIEw(PhoneWindow.java:1886)W/WindowManager( 2365): at
com.androID.internal.policy.impl.PhoneWindowManager.addStartingWindow(PhoneWindowManager.java:2639)W/WindowManager( 2365): at
com.androID.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:9140)W/WindowManager( 2365): at
androID.os.Handler.dispatchMessage(Handler.java:102)W/WindowManager( 2365): at androID.os.Looper.loop(Looper.java:146)
W/WindowManager( 2365): at adroID.os.HandlerThread.run(HandlerThread.java:61)
D/PointerIcon( 2365): setMouseIconStyle1 pointerType: 1001iconType:101
flag:0D/PointerIcon( 2365): setMouseCustomIcon IconType is same.101
I/BeaconService( 4802): beaconService version 2.0-samsung1 is starting
upI/BeaconService( 4802): SDK is 18 or higher. Using native AndroID
APIs for BLE scanningD/Phonestatusbar( 2551): setTransGradationMode=false,
mMultiWindowMode=falseW/ResourceType( 2365): No kNown package when getting value for
resource number 0x7f020000W/WindowManager( 2365): Token{4335a9f8 ActivityRecord{4335a880 u0
org.altbeacon.beaconreference/.RangingActivity t3}} Failed creating
starting windowW/WindowManager( 2365):
androID.content.res.Resources$NotFoundException: Resource ID #0x7f020000W/WindowManager( 2365): at
androID.content.res.Resources.getValue(Resources.java:2354)W/WindowManager( 2365): at
androID.content.res.Resources.getDrawable(Resources.java:1919)W/WindowManager( 2365): at
com.androID.internal.Widget.ActionbarVIEw.setIcon(ActionbarVIEw.java:1037)W/WindowManager( 2365): at
com.androID.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3478)W/WindowManager( 2365): at
com.androID.internal.policy.impl.PhoneWindow.getDecorVIEw(PhoneWindow.java:1886)W/WindowManager( 2365): at
com.androID.internal.policy.impl.PhoneWindowManager.addStartingWindow(PhoneWindowManager.java:2639)W/WindowManager( 2365): at
com.androID.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:9140)W/WindowManager( 2365): at
androID.os.Handler.dispatchMessage(Handler.java:102)W/WindowManager( 2365): at androID.os.Looper.loop(Looper.java:146)
W/WindowManager( 2365): at androID.os.HandlerThread.run(HandlerThread.java:61)D/BtGatt.GattService( 3581): onScanResult() –
address=F4:B8:5E:E4:BA:4A,RSSi=-53D/BtGatt.GattService( 3581): Binder is dead – unregistering clIEnt
(5)!E/BtGatt.GattService( 3581): Exception: androID.os.DeadobjectException
W/inputdispatcher( 2365): channel ~ Consumer closed input channel or
an error occurred. events=0x9I/windowstate( 2365): WIN DEATH: Window{43379c08 u0
org.altbeacon.beaconreference/org.altbeacon.beaconreference.RangingActivity}E/inputdispatcher( 2365): channel ~ Channel is unrecoverably broken
and will be disposed!W/inputdispatcher( 2365): Attempted to unregister already unregistered
I/windowstate( 2365): WIN DEATH: Window{43366f58 u0 org.altbeacon.beaconreference/org.altbeacon.beaconreference.MonitoringActivity}
input channel
我的应用程序正确检测到范围内的所有信标,但我需要一个工作后台服务才能长时间工作.
你能告诉我我做错了什么吗?
编辑
我可以假设,如果我看到“1进程和1个服务”的应用程序在运行程序列表中,则该服务处于活动状态且正在运行,如果我看不到该进程未运行?
我将运行我的服务,直到我的活动在后台运行.当我的应用程序被用户清除时,我将停止扫描所有信标.
我的意见是只有当有限的活动正在运行时运行服务或者只是停止服务.这也将影响设备电池.
要将服务绑定到活动,您可以查看here.
希望它会有所帮助.
总结以上是内存溢出为你收集整理的Beacon后台服务有时会被Android杀死全部内容,希望文章能够帮你解决Beacon后台服务有时会被Android杀死所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)