在某些设备中,Android App被操作系统杀死

时间:2017-04-19 06:20:19

标签: android android-mapview osmdroid

我有一个Android应用程序从蓝牙获取数据并在osmroid Mapview上连续绘制这些数据,但在一定时间后操作系统杀死了这个应用程序,但这只发生在某个设备上。

这种杀戮在HTC,三星设备中不会发生。

请帮助我找出某些设备中发生的原因。另外,请为我提供解决此问题的方法。

04-17 13:16:06.594 12536-12536/? I/ContextImpl: startServiceCommon service:Intent { cmp=com.google.android.gms/.checkin.EventLogService (has extras) }, user:UserHandle{0}
04-17 13:16:06.603 1016-1016/? D/SettingsInterface:  from settings cache , name = turn_silent , value = null
04-17 13:16:06.603 1016-1016/? D/SettingsInterface:  from settings cache , name = callsilent , value = null
04-17 13:16:06.603 1016-1016/? D/SettingsInterface:  from settings cache , name = alarmsilent , value = null
04-17 13:16:06.603 1016-1016/? D/SettingsInterface:  from settings cache , name = musicsilent , value = null
04-17 13:16:06.603 1016-1016/? D/SettingsInterface:  from settings cache , name = mediasilent , value = null
04-17 13:16:06.603 1016-1016/? I/fanzhuan: onSensorChanged front----> 0.104  0.005  9.846
04-17 13:16:06.612 1016-1026/? I/ActivityManager: startServiceLocked service:Intent { cmp=com.google.android.gms/.checkin.EventLogService (has extras) }
04-17 13:16:06.644 1016-1772/? D/PowerManagerService: acquireWakeLockInternal: lock=249043682, flags=0x1, tag="wake:com.google.android.gms/.checkin.EventLogService", ws=null, uid=10011, pid=12536
04-17 13:16:06.652 1016-1772/? I/muxinwu: PowerManagerService agoldReleaseWakelock mPackageName:android, mTag:WindowManager
04-17 13:16:06.652 1016-1772/? I/muxinwu: PowerManagerService agoldReleaseWakelock package_name = com.google.android.gms, tag_name = *net_scheduler*
04-17 13:16:06.652 1016-1772/? I/muxinwu: PowerManagerService agoldReleaseWakelock package_name = com.google.android.gms, tag_name = Checkin Service
04-17 13:16:06.652 1016-1772/? I/muxinwu: PowerManagerService agoldReleaseWakelock mPackageName:android, mTag:*alarm*
04-17 13:16:06.652 1016-1772/? I/muxinwu: PowerManagerService agoldReleaseWakelock package_name = com.google.android.gms, tag_name = *net_scheduler*
04-17 13:16:06.653 1016-1772/? I/muxinwu: PowerManagerService agoldReleaseWakelock package_name = com.google.android.gms, tag_name = Checkin Service
04-17 13:16:06.653 1016-1772/? D/PowerManagerService: updateWakeLockSummaryLocked: mWakefulness=Awake, mWakeLockSummary=0x23
04-17 13:16:06.654 1016-1772/? D/PowerManagerService: updateUserActivitySummaryLocked: mWakefulness=Awake, mUserActivitySummary=0x1, nextTimeout=8355076 (in 1778733 ms)
04-17 13:16:06.657 1016-1772/? D/DisplayPowerController: requestPowerState: policy=BRIGHT, useProximitySensor=false, screenBrightness=240, screenAutoBrightnessAdjustment=0.0, brightnessSetByUser=true, useAutoBrightness=false, blockScreenOn=false, lowPowerMode=false, boostScreenBrightness=false, dozeScreenBrightness=-1, dozeScreenState=UNKNOWN, waitForNegativeProximity=false
04-17 13:16:06.658 1016-1772/? I/PowerManagerService: setBrightness mButtonLight 0.
04-17 13:16:06.658 1016-1772/? D/PowerManagerService: updateDisplayPowerStateLocked: mDisplayReady=true, policy=3, mWakefulness=1, mWakeLockSummary=0x23, mUserActivitySummary=0x1, mBootCompleted=true, mScreenBrightnessBoostInProgress=false
04-17 13:16:06.659 1016-1772/? D/PowerManagerNotifier: onWakeLockAcquired: flags=1, tag="wake:com.google.android.gms/.checkin.EventLogService", packageName=com.google.android.gms, ownerUid=10011, ownerPid=12536, workSource=null
04-17 13:16:06.663 1016-1772/? D/AppOps: startOperation: allowing code 40 uid 10011 package com.google.android.gms
04-17 13:16:06.679 12536-12536/? D/ActivityThread: BDC-RECEIVER handled : 0 / ReceiverData{intent=Intent { flg=0x114 cmp=com.google.android.gms/.checkin.EventLogServiceReceiver (has extras) } packageName=com.google.android.gms resultCode=0 resultData=null resultExtras=null}
04-17 13:16:06.686 1016-1016/? D/AlarmManager: onSendFinished begin
04-17 13:16:06.691 1016-1016/? D/PowerManagerService: releaseWakeLockInternal: lock=141471969 [*alarm*], flags=0x0, total_time=2031ms
04-17 13:16:06.694 12536-12536/? D/ActivityThread: SVC-Creating service: CreateServiceData{token=android.os.BinderProxy@fff5a58 className=com.google.android.gms.checkin.EventLogService packageName=com.google.android.gms intent=null}
04-17 13:16:06.696 12536-12536/? D/ActivityThread: SVC-CREATE_SERVICE handled : 0 / CreateServiceData{token=android.os.BinderProxy@fff5a58 className=com.google.android.gms.checkin.EventLogService packageName=com.google.android.gms intent=null}
04-17 13:16:06.696 12536-12536/? D/ActivityThread: SVC-Calling onStartCommand: com.google.android.gms.checkin.EventLogService@55077b1, flags=0, startId=1
04-17 13:16:06.721 1016-1016/? D/PowerManagerNotifier: onWakeLockReleased: flags=1, tag="*alarm*", packageName=android, ownerUid=1000, ownerPid=1016, workSource=WorkSource{10011}
04-17 13:16:06.722 1016-1016/? D/PowerManagerService: updateWakeLockSummaryLocked: mWakefulness=Awake, mWakeLockSummary=0x23
04-17 13:16:06.722 1016-1016/? D/PowerManagerService: updateUserActivitySummaryLocked: mWakefulness=Awake, mUserActivitySummary=0x1, nextTimeout=8355076 (in 1778665 ms)
04-17 13:16:06.722 1016-1016/? D/DisplayPowerController: requestPowerState: policy=BRIGHT, useProximitySensor=false, screenBrightness=240, screenAutoBrightnessAdjustment=0.0, brightnessSetByUser=true, useAutoBrightness=false, blockScreenOn=false, lowPowerMode=false, boostScreenBrightness=false, dozeScreenBrightness=-1, dozeScreenState=UNKNOWN, waitForNegativeProximity=false
04-17 13:16:06.722 1016-1016/? I/PowerManagerService: setBrightness mButtonLight 0.
04-17 13:16:06.722 1016-1016/? D/PowerManagerService: updateDisplayPowerStateLocked: mDisplayReady=true, policy=3, mWakefulness=1, mWakeLockSummary=0x23, mUserActivitySummary=0x1, mBootCompleted=true, mScreenBrightnessBoostInProgress=false
04-17 13:16:06.727 1016-10160/? D/PowerManagerService: acquireWakeLockInternal: lock=117472883, flags=0x1, tag="Event Log Service", ws=WorkSource{10011 com.google.android.gms}, uid=10011, pid=12536
04-17 13:16:06.727 1016-10160/? I/muxinwu: PowerManagerService agoldReleaseWakelock mPackageName:android, mTag:WindowManager
04-17 13:16:06.727 1016-10160/? I/muxinwu: PowerManagerService agoldReleaseWakelock package_name = com.google.android.gms, tag_name = *net_scheduler*
04-17 13:16:06.727 1016-10160/? I/muxinwu: PowerManagerService agoldReleaseWakelock package_name = com.google.android.gms, tag_name = Checkin Service
04-17 13:16:06.728 1016-10160/? I/muxinwu: PowerManagerService agoldReleaseWakelock mPackageName:com.google.android.gms, mTag:wake:com.google.android.gms/.checkin.EventLogService
04-17 13:16:06.728 1016-10160/? I/muxinwu: PowerManagerService agoldReleaseWakelock package_name = com.google.android.gms, tag_name = *net_scheduler*
04-17 13:16:06.728 1016-10160/? I/muxinwu: PowerManagerService agoldReleaseWakelock package_name = com.google.android.gms, tag_name = Checkin Service
04-17 13:16:06.728 1016-10160/? D/PowerManagerService: updateWakeLockSummaryLocked: mWakefulness=Awake, mWakeLockSummary=0x23
04-17 13:16:06.728 1016-10160/? D/PowerManagerService: updateUserActivitySummaryLocked: mWakefulness=Awake, mUserActivitySummary=0x1, nextTimeout=8355076 (in 1778659 ms)
04-17 13:16:06.728 1016-10160/? D/DisplayPowerController: requestPowerState: policy=BRIGHT, useProximitySensor=false, screenBrightness=240, screenAutoBrightnessAdjustment=0.0, brightnessSetByUser=true, useAutoBrightness=false, blockScreenOn=false, lowPowerMode=false, boostScreenBrightness=false, dozeScreenBrightness=-1, dozeScreenState=UNKNOWN, waitForNegativeProximity=false
04-17 13:16:06.728 1016-10160/? I/PowerManagerService: setBrightness mButtonLight 0.
04-17 13:16:06.728 1016-10160/? D/PowerManagerService: updateDisplayPowerStateLocked: mDisplayReady=true, policy=3, mWakefulness=1, mWakeLockSummary=0x23, mUserActivitySummary=0x1, mBootCompleted=true, mScreenBrightnessBoostInProgress=false
04-17 13:16:06.728 1016-10160/? D/PowerManagerNotifier: onWakeLockAcquired: flags=1, tag="Event Log Service", packageName=com.google.android.gms, ownerUid=10011, ownerPid=12536, workSource=WorkSource{10011 com.google.android.gms}
04-17 13:16:06.730 1016-1144/? D/PowerManagerService: releaseWakeLockInternal: lock=249043682 [wake:com.google.android.gms/.checkin.EventLogService], flags=0x0, total_time=77ms
04-17 13:16:06.730 1016-1144/? D/PowerManagerNotifier: onWakeLockReleased: flags=1, tag="wake:com.google.android.gms/.checkin.EventLogService", packageName=com.google.android.gms, ownerUid=10011, ownerPid=12536, workSource=null
04-17 13:16:06.730 1016-1144/? D/PowerManagerService: updateWakeLockSummaryLocked: mWakefulness=Awake, mWakeLockSummary=0x23
04-17 13:16:06.730 1016-1144/? D/PowerManagerService: updateUserActivitySummaryLocked: mWakefulness=Awake, mUserActivitySummary=0x1, nextTimeout=8355076 (in 1778657 ms)
04-17 13:16:06.730 1016-1144/? D/DisplayPowerController: requestPowerState: policy=BRIGHT, useProximitySensor=false, screenBrightness=240, screenAutoBrightnessAdjustment=0.0, brightnessSetByUser=true, useAutoBrightness=false, blockScreenOn=false, lowPowerMode=false, boostScreenBrightness=false, dozeScreenBrightness=-1, dozeScreenState=UNKNOWN, waitForNegativeProximity=false
04-17 13:16:06.730 1016-1144/? I/PowerManagerService: setBrightness mButtonLight 0.
04-17 13:16:06.730 1016-1144/? D/PowerManagerService: updateDisplayPowerStateLocked: mDisplayReady=true, policy=3, mWakefulness=1, mWakeLockSummary=0x23, mUserActivitySummary=0x1, mBootCompleted=true, mScreenBrightnessBoostInProgress=false
04-17 13:16:06.755 12536-12536/? D/ActivityThread: SVC-SERVICE_ARGS handled : 0 / ServiceArgsData{token=android.os.BinderProxy@fff5a58 startId=1 args=Intent { cmp=com.google.android.gms/.checkin.EventLogService (has extras) }}
04-17 13:16:06.803 1016-1016/? D/SettingsInterface:  from settings cache , name = turn_silent , value = null
04-17 13:16:06.803 1016-1016/? D/SettingsInterface:  from settings cache , name = callsilent , value = null
04-17 13:16:06.803 1016-1016/? D/SettingsInterface:  from settings cache , name = alarmsilent , value = null
04-17 13:16:06.803 1016-1016/? D/SettingsInterface:  from settings cache , name = musicsilent , value = null
04-17 13:16:06.803 1016-1016/? D/SettingsInterface:  from settings cache , name = mediasilent , value = null
04-17 13:16:06.804 1016-1016/? I/fanzhuan: onSensorChanged front----> 0.089  0.005  9.853
04-17 13:16:06.833 12536-12583/? I/ContextImpl: bindServiceCommon service:Intent { act=com.google.android.gms.usagereporting.service.START pkg=com.google.android.gms }
04-17 13:16:06.835 1016-1716/? I/ActivityManager: bindServiceLocked service:Intent { act=com.google.android.gms.usagereporting.service.START pkg=com.google.android.gms }
04-17 13:16:06.845 1016-1716/? W/PackageManager: checkUidPermission(): android.permission.WRITE_MEDIA_STORAGE of 10011 is denied.
04-17 13:16:06.857 1016-1716/? I/ActivityManager: Start proc 12584:com.google.android.gms.persistent/u0a11 for service com.google.android.gms/.usagereporting.service.UsageReportingService
04-17 13:16:06.857 1016-1716/? I/ActivityManager: [Background Service Priority Adjustment] Process.setProcessGroup to Process.THREAD_GROUP_BG_NONINTERACTIVE, app.pid: 12584
04-17 13:16:07.003 1016-1016/? D/SettingsInterface:  from settings cache , name = turn_silent , value = null
04-17 13:16:07.003 1016-1016/? D/SettingsInterface:  from settings cache , name = callsilent , value = null
04-17 13:16:07.003 1016-1016/? D/SettingsInterface:  from settings cache , name = alarmsilent , value = null
04-17 13:16:07.003 1016-1016/? D/SettingsInterface:  from settings cache , name = musicsilent , value = null
04-17 13:16:07.003 1016-1016/? D/SettingsInterface:  from settings cache , name = mediasilent , value = null
04-17 13:16:07.003 1016-1016/? I/fanzhuan: onSensorChanged front----> 0.05  0.032  9.864
04-17 13:16:07.030 12584-12591/? I/System: FinalizerDaemon: finalize objects = 1
04-17 13:16:07.041 12584-12584/? I/LoadedApk: No resource references to update in package FFFFFFFFFFFFFFFFFFFFFF
04-17 13:16:07.041 12584-12584/? D/ActivityThread: installProvider: context.getPackageName()=com.google.android.gms
04-17 13:16:07.050 12584-12584/? D/ActivityThread: installProvider: context.getPackageName()=com.google.android.gms
04-17 13:16:07.051 12584-12584/? D/ActivityThread: installProvider: context.getPackageName()=com.google.android.gms
04-17 13:16:07.053 12584-12584/? D/ActivityThread: installProvider: context.getPackageName()=com.google.android.gms
04-17 13:16:07.056 12584-12584/? D/ActivityThread: installProvider: context.getPackageName()=com.google.android.gms
04-17 13:16:07.058 12584-12584/? D/ActivityThread: installProvider: context.getPackageName()=com.google.android.gms
04-17 13:16:07.059 12584-12584/? D/ActivityThread: installProvider: context.getPackageName()=com.google.android.gms
04-17 13:16:07.060 12584-12584/? D/ActivityThread: installProvider: context.getPackageName()=com.google.android.gms
04-17 13:16:07.062 12584-12584/? D/ActivityThread: installProvider: context.getPackageName()=com.google.android.gms

    tyManager: SVC-mBroadcastQueues: com.android.server.am.BroadcastQueue@4d6409c
04-17 13:16:04.882 1016-1016/? E/AppWidgetServiceImpl: Error clearing service interface
                                                       android.os.DeadObjectException
                                                           at android.os.BinderProxy.transactNative(Native Method)
                                                           at android.os.BinderProxy.transact(Binder.java:511)
                                                           at com.android.internal.widget.IRemoteViewsAdapterConnection$Stub$Proxy.onServiceDisconnected(IRemoteViewsAdapterConnection.java:95)
                                                           at com.android.server.appwidget.AppWidgetServiceImpl$ServiceConnectionProxy.disconnect(AppWidgetServiceImpl.java:3546)
                                                           at com.android.server.appwidget.AppWidgetServiceImpl$ServiceConnectionProxy.onServiceDisconnected(AppWidgetServiceImpl.java:3541)
                                                           at android.app.LoadedApk$ServiceDispatcher.doDeath(LoadedApk.java:1269)
                                                           at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1283)
                                                           at android.os.Handler.handleCallback(Handler.java:815)
                                                           at android.os.Handler.dispatchMessage(Handler.java:104)
                                                           at android.os.Looper.loop(Looper.java:207)
                                                           at com.android.server.SystemServer.run(SystemServer.java:371)
                                                           at com.android.server.SystemServer.main(SystemServer.java:234)
                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
04-17 13:16:04.882 1605-1697/? D/ForegroundUtils: Process died; UID 10041 PID 12520
04-17 13:16:04.883 1605-1697/? D/ForegroundUtils:   foregroundPids.delete(pid) 12520
04-17 13:16:04.883 1605-1697/? D/ForegroundUtils:   mForegroundUidPids.remove  uid:10041
04-17 13:16:04.883 1605-1697/? D/ForegroundUtils:   handleUidToBackground  uid:10041
04-17 13:16:04.883 1605-1697/? D/ForegroundUtils: Foreground changed, PID: 12520 UID: 10041 foreground: false
04-17 13:16:04.883 1605-1697/? D/ForegroundUtils: Foreground UID/PID combinations:
04-17 13:16:04.883 1605-1697/? D/ForegroundUtils: UID: 10188 PID: 7988

1 个答案:

答案 0 :(得分:1)

在kitkat中,当你从最近的应用程序中杀死它时,Os会杀死一个粘性服务。所以这也是我遇到的操作系统特定问题。我还尝试重新启动Service onTaskRemoved()。但Kitkat(联想设备)似乎没有运气。

  @Override
public void onTaskRemoved(Intent rootIntent) {
    Log.e("Task","Removed");
    Intent restartService = new Intent(getApplicationContext(),
            this.getClass());
    restartService.setPackage(getPackageName());
    PendingIntent restartServicePI = PendingIntent.getService(
            getApplicationContext(), 1, restartService,
            PendingIntent.FLAG_ONE_SHOT);
    AlarmManager alarmService = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
    alarmService.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 1000, restartServicePI);

}

虽然它可以在其他设备上使用。所以我最终以AlarmManager结束检查服务是否在某个时间间隔运行。 但在使用此功能之前,请阅读有关电池优化和打盹模式{3}}的Android M和Android N规范。