0

私はそのようなことをしたいと思います:

@Override
protected String doInBackground(Object... params) {     
    int i = 0;
    int max = Integer.MAX_VALUE;
    GPSTracker gps = new GPSTracker(context);
    do
    {
        //Something

    } while(10 seconds);

    return null;

}

whileステートメントにカウント時間を入れる方法. これを10秒で作りたい。

4

5 に答える 5

2

タスクを定期的に実行する場合は、 を使用しますTimer#scheduleAtFixedRate

于 2013-08-29T16:44:12.557 に答える
0

やったよ:

long start = System.currentTimeMillis();
long end = start + 60*1000; // 60 seconds * 1000 ms/sec
while (System.currentTimeMillis() < end)
{
    // run
}

すべての回答に感謝します。

于 2013-08-29T17:09:40.827 に答える