
这只发生在三星S3(而不是在S2上).
我认为这是内存相关的,因为我的应用程序非常内存密集(它正在从网络加载大量的图像),但是我看不到日志中没有任何内存错误.
我也怀疑我使用的http框架可能是错误的,所以我从Apache httpComponents切换到java.net.httpURLConnection,但没有帮助.
任何关于为什么发生这种情况的想法或提示如何调试它将不胜感激.
这是从日志中显示一些后台进程死亡的摘录(例如,动态壁纸):
01-07 01:57:37.245: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x101-07 01:57:37.505: D/dalvikvm(29490): GC_FOR_ALLOC freed 1535K,17% free 28032K/33735K,paused 71ms,total 71ms01-07 01:57:37.580: D/dalvikvm(6718): WAIT_FOR_CONCURRENT_GC blocked 0ms01-07 01:57:37.620: D/dalvikvm(6718): GC_EXPliCIT freed 91K,9% free 17663K/19399K,paused 3ms+5ms,total 40ms01-07 01:57:38.190: I/inputReader(2296): touch event's action is 0x0 (deviceType=0) [pCnt=1,s=0.428 ]01-07 01:57:38.190: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x001-07 01:57:38.190: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x001-07 01:57:38.190: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x001-07 01:57:38.190: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x001-07 01:57:38.190: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x001-07 01:57:38.335: I/inputReader(2296): touch event's action is 0x1 (deviceType=0) [pCnt=1,s=]01-07 01:57:38.335: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x101-07 01:57:38.335: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x101-07 01:57:38.335: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x101-07 01:57:38.750: D/dalvikvm(29490): GC_FOR_ALLOC freed 1688K,18% free 27981K/33735K,paused 114ms,total 114ms01-07 01:57:39.695: W/PowerManagerService(2296): Timer 0x3->0x3|0x001-07 01:57:39.700: D/PowerManagerService(2296): setTimeoutLocked::SmartSleep : after1950001-07 01:57:39.930: I/inputReader(2296): touch event's action is 0x0 (deviceType=0) [pCnt=1,s=0.429 ]01-07 01:57:39.930: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x001-07 01:57:39.930: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x001-07 01:57:39.930: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x001-07 01:57:39.930: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x001-07 01:57:39.930: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x001-07 01:57:40.020: D/DeviceInfo(2296): SysScope Service has unexpectedly disconnected!01-07 01:57:40.065: I/inputReader(2296): touch event's action is 0x1 (deviceType=0) [pCnt=1,s=]01-07 01:57:40.065: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x101-07 01:57:40.065: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x101-07 01:57:40.065: I/inputdispatcher(2296): Delivering touch to current input target: action: 0x1**01-07 01:57:40.080: I/ActivityManager(2296): Process com.androID.smspush (pID 28031) (adj 1) has dIEd.**01-07 01:57:40.090: W/WallpaperService(2296): Wallpaper service gone: ComponentInfo{com.sec.ccl.csp.app.secretwallpaper.themetwo/com.sec.ccl.csp.app.secretwallpaper.themetwo.SecretWallpaperService}01-07 01:57:40.125: D/KeyguardVIEwMediator(2296): setHIDden false**01-07 01:57:40.135: I/ActivityManager(2296): Process com.androID.server.device.enterprise:remote (pID 28016) (adj 1) has dIEd.****01-07 01:57:40.145: I/ActivityManager(2296): Process com.sec.ccl.csp.app.secretwallpaper.themetwo (pID 29715) (adj 1) has dIEd.**01-07 01:57:40.285: D/dalvikvm(29490): GC_CONCURRENT freed 1616K,17% free 28289K/33735K,paused 27ms+21ms,total 178ms01-07 01:57:40.285: D/dalvikvm(29490): WAIT_FOR_CONCURRENT_GC blocked 112ms01-07 01:57:40.445: D/dalvikvm(2296): GC_CONCURRENT freed 1869K,59% free 24186K/57991K,paused 26ms+12ms,total 197ms01-07 01:57:40.660: D/dalvikvm(29490): GC_CONCURRENT freed 1587K,16% free 28622K/33735K,paused 3ms+7ms,total 51ms01-07 01:57:40.685: D/KeyguardVIEwMediator(2296): setHIDden false解决方法 背景过程有三个主要原因,我将从少到最可能: 你自问,要求它停下来
检查您的代码是否存在尴尬情况可能要求停止服务的错误.这可能在您的应用程序的服务或其他活动中.
未捕获的异常
该服务遇到了一个未被捕获的例外.在这种情况下,您应该能够看到日志中的信息,但日志不会持续很久,您可能会丢失它.
为了解决这个可能性,你可以像这样设置一个DefaultUncaughtExceptionHandler:
UncaughtExceptionHandler currentHandler = Thread.getDefaultUncaughtExceptionHandler();if (!(currentHandler instanceof DefaultExceptionHandler)) { // Register default exceptions handler Thread.setDefaultUncaughtExceptionHandler( new DefaultExceptionHandler(currentHandler));} 并定义您的DefaultExceptionHandler类写入一个临时文件,如下所示:
public class DefaultExceptionHandler implements UncaughtExceptionHandler { private UncaughtExceptionHandler defaultExceptionHandler; public DefaultExceptionHandler(UncaughtExceptionHandler pDefaultExceptionHandler) { defaultExceptionHandler = pDefaultExceptionHandler; } public voID uncaughtException(Thread t,Throwable e) { final Writer result = new StringWriter(); final PrintWriter printWriter = new PrintWriter(result); e.printstacktrace(printWriter); try { String filename = "your_temp_filename"; BuffereDWriter bw = new BuffereDWriter(new fileWriter(filename)); bw.write(result.toString()); bw.flush(); bw.close(); } catch (Exception e2) { e2.printstacktrace(); } defaultExceptionHandler.uncaughtException(t,e); }} AndroID *** 作系统要求服务停止
根据您的描述,这是最可能的原因,而您对此的控制较少.
没有办法阻止AndroID在需要附加资源或相信您的服务运行时间过长时杀死您的应用程序.允许服务在被杀死之前运行的时间可能会从设备更改为设备,因为它取决于分配的资源(即,图像内存需求随屏幕大小变化)和可用资源.
在这种情况下,您唯一可以做的事情就是开始使用前台服务进行服务:
startForeground(int ID,Notification notification);
这通知 *** 作系统,您的服务具有用户可见性,并且将被置于不太可能杀死服务的列表.我使用几个设备的经验是,即使您同时使用其他几个应用程序,该服务也不会中断运行.
问候.
总结以上是内存溢出为你收集整理的android – 在三星S3上运行应用程序时,后台进程随机死机全部内容,希望文章能够帮你解决android – 在三星S3上运行应用程序时,后台进程随机死机所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)