【发布时间】:2015-12-22 10:32:40
【问题描述】:
我正在制作一个应用程序,它几乎完成了。直到应用程序由于内存泄漏或其他原因一直冻结。有没有人可以解决这个问题?哦,是的,它是在添加倒数计时器后发生的。这是我的一些代码:'
while(methodCounter<1){ new CountDownTimer(60000, 1000) {
//methodcounter is the amount of times the method is called
public void onTick(long millisUntilFinished) {
Timer.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
startActivity(new Intent(MainActivity.this, AlertDialogClass.class));
}
}.start();
}`
这是我的一些日志:
12-22 11:31:03.096 7109-7109/com.liammertensbe.com.typefaster D/dalvikvm: GC_FOR_ALLOC freed 3040K (77707), 39% free 4952K/8048K, paused 27ms, total 28ms
12-22 11:31:03.444 7109-7109/com.liammertensbe.com.typefaster D/dalvikvm: GC_FOR_ALLOC freed 3040K (77707), 39% free 4952K/8048K, paused 28ms, total 28ms
12-22 11:31:03.791 7109-7109/com.liammertensbe.com.typefaster D/dalvikvm: GC_FOR_ALLOC freed 3040K (77705), 39% free 4952K/8048K, paused 27ms, total 27ms
12-22 11:31:04.140 7109-7109/com.liammertensbe.com.typefaster D/dalvikvm: GC_FOR_ALLOC freed 3040K (77707), 39% free 4952K/8048K, paused 27ms, total 27ms
【问题讨论】:
-
在哪里增加methodCounter?
-
在名为 check() 的方法中
-
check() 在哪里被调用?
-
在 ontextChangedListener 中
标签: java android memory android-studio crash