http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AlarmService_Service.htmlを参照しています
スレッドの実行可能ファイルは次のようになります
Runnable mTask = new Runnable()
{
public void run()
{
Log.v("service", "thread is running after 5 min");
// Normally we would do some work here... for our sample, we will
// just sleep for 30 seconds.
long endTime = System.currentTimeMillis() + 15*1000;
while (System.currentTimeMillis() < endTime)
{
synchronized (mBinder)
{
try
{
mBinder.wait(endTime - System.currentTimeMillis());
}
catch (Exception e)
{
}
}
} // Done with our work... stop the service!
AlarmService_Service.this.stopSelf();
}
}
同期の概念に問題があることを認めます...スレッドはwhileループを実行して15秒間待機し、そのループ内で15秒間待機します。では、Log.v(TAG、TEXT);などのログエントリを書き込みたいだけの場合、ランナブルはどのようになりますか?自分のデータベーステーブルに新しいエントリを書き込みたい場合、何が変わりますか?
ありがとう、A。