当前位置:编程学习 > wap >>

android待机后后台service工作异常

android待机后后台service工作异常

小弟我用service做了一个后台定时发送基站信息到服务器实现基站定位的程序,不待机的情况下使用
"GsmCellLocation gcl = (GsmCellLocation) telephonyManager.getCellLocation();
gcl.getCid();"的方法是可以获取到cellid的,程序正常,进入待机模式后程序还是一直运行,但是"gcl.getCid"返回值为"null";
我的测试机器是G7 android2.2的系统,是不是系统进入休眠状态了就无法获取了,如何解决这个问题呢?

请各位兄弟们帮帮忙啊!! --------------------编程问答-------------------- 待机的情况下service不正常工作,你这个情况我遇到过,要设置一下PowerManager,让待机的情况下也能分配到cpu,具体怎么设置SDK上说的很清楚,我就不多说了.... --------------------编程问答--------------------
引用 1 楼 raoyongchao 的回复:
待机的情况下service不正常工作,你这个情况我遇到过,要设置一下PowerManager,让待机的情况下也能分配到cpu,具体怎么设置SDK上说的很清楚,我就不多说了....

是不是在onCreate()里添加下面的代码?
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"");        
wakeLock.acquire();

添加后问题依然存在啊

--------------------编程问答-------------------- 问题还是没有解决啊,自己顶一个 --------------------编程问答-------------------- 我要疯了 --------------------编程问答-------------------- 咋会出现这档子事儿呢 还米牛遇到过嘞、  帮顶、 --------------------编程问答-------------------- 谢谢楼上的兄弟了,

可惜问题还是没有解决啊 --------------------编程问答-------------------- --------------------编程问答-------------------- Indicates the current state of the screen.  When the screen is off, the
 * RIL should notify the baseband to suppress certain notifications (eg,
 * signal strength and changes in LAC or CID) in an effort to conserve power.
 * These notifications should resume when the screen is on.

无法修复的问题,除非改底层,这个事件是在screen off的时候触发的,不是待机的时候,你咋让他不休眠都没用,除非让他屏幕常亮,但是太费电了 --------------------编程问答--------------------
引用 8 楼 jalu_515 的回复:
Indicates the current state of the screen.  When the screen is off, the
 * RIL should notify the baseband to suppress certain notifications (eg,
 * signal strength and changes in LAC or CID) in an ……

2.2之前的版本是可以的,我在真机上测试过 --------------------编程问答-------------------- 问题还是没有解决啊,求助啊! --------------------编程问答-------------------- 问题还是没有解决啊,求助啊! --------------------编程问答--------------------
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,