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

解决方案 »

  1.   

    待机的情况下service不正常工作,你这个情况我遇到过,要设置一下PowerManager,让待机的情况下也能分配到cpu,具体怎么设置SDK上说的很清楚,我就不多说了....
      

  2.   

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

  3.   

    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的时候触发的,不是待机的时候,你咋让他不休眠都没用,除非让他屏幕常亮,但是太费电了