次の面白い問題に行き詰まりました。
private Object lock=new Object();
public void letsSayMain(){
timer=new Timer();
task=new RequestMessages();
timer.schedule(task, FIRST_DELAY, period*60*1000); //period = 10, FIRST_DELAY=10*1000
}
private class RequestMessages extends TimerTask{
public void run() {
synchronized(lock){
foo();
Log.d(ApplicationConstants.APPLICATION_CLASS_NAME, "Yay, we've just exited the method!");
}
}
private void foo(){
.
.
//Notification initialization
.
.
Log.d(ApplicationConstants.APPLICATION_CLASS_NAME, "We've about to show the notification.");
mNotificationManager.notify(z, notificationTransactions); //z is unique int, starting from 1. notificationTransaction - forged notification.
Log.d(ApplicationConstants.APPLICATION_CLASS_NAME, "We've shoved the notification.");
}
};
出力は次のとおりです。
07-09 05:23:50.864: DEBUG/AllApp(6919): We've about to show the notification.
それだけです。
mNotificationManager.notify() の呼び出し後、問題の内容と、スレッド コードの実行が終了する理由を教えてもらえますか ???
ちなみに、タイマーはまだ実行されており、さらに 10 分後にそのコードが再度実行されます。タイマーは、独自のスレッドでコードを実行します。タイマースレッドが終了してすぐに再起動するかどうかはわかりませんが、スレッドは無傷のようですが、トップレベルのスタック関数のみを実行します(タイマーを再度カウントするだけです)。
Android にも通知が表示されます。
私はそのnotify()をforサイクルに埋め込んでいるので、mNotificationManager.notify()の呼び出し後に実行を継続することが重要です。
EDIT1:それは本当に静かなクラッシュのようです:
PathClassLoader(ClassLoader).loadClass(String) line: 532
INotificationManager$Stub$Proxy.enqueueNotification(String, int, Notification, int[]) line: 157
NotificationManager.notify(int, Notification) line: 94
.
.
.
次のステップは 1 行です。
Timer$TimerImpl.run() line: 294
クラッシュの前に、
PathClassLoader(ClassLoader).loadClass(String, boolean) 行: 563
が 2 回繰り返し実行されましたが、PathClassLoader(ClassLoader).loadClass(String) 行: 532 の 1 行からだけです。 - loadClass(String) に戻り、次の瞬間 - すべて吹き飛ばされます。
何か提案 - 私は今何をすべきですか?? 私はこれまでサイレントクラッシュに直面したことがありません...