比较android中的长时间值让我在android htc手机中总是假的

时间:2011-08-28 04:14:13

标签: android

下面是我的代码,它在模拟器中运行得很完美但在htc

中根本不起作用
   void run()
{
 long updateStart=System.currentTimeMillis();
 long comapartime=(updateStart+30000);
        while((currentByte=stream.read())!=-1)
        {    
            bytesIn++;          

            if(System.currentTimeMillis()>=comapartime) \\always gives false in device but gives true in emulator
            {
                                    updateStart=System.currentTimeMillis();
                comapartime=(updateStart+30000);
            }
                     }

}

1 个答案:

答案 0 :(得分:0)

试试这个:

void run()
{
 long updateStart=System.currentTimeMillis();
 long comapartime=(updateStart+30000);
        while((currentByte=stream.read())!=-1)
        {    
            bytesIn++;          
            long tmp = System.currentTimeMillis(); // set a break point here, is it returning 0 on device?
            if(tmp>=comapartime) \\always gives false in device but gives true in emulator
            {
                                    updateStart=System.currentTimeMillis();
                comapartime=(updateStart+30000);
            }
        }
}