活动暂停时崩溃
我有一个活动在暂停时不断崩溃。有一条环形线可以在画布上绘画。当我暂停应用程序或尝试移动到另一个活动时,它崩溃了。
我有它,所以它会在暂停时关闭,因为我不希望它强制关闭。但我希望能够回到活动中
@Override
public void surfaceDestroyed(SurfaceHolder arg0) {
// TODO Auto-generated method stub
boolean retry = true;
_canDraw = false;
while(retry) {
try {
DrawThread.join();
retry = false;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
android.os.Process.killProcess(android.os.Process.myPid());
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
android.os.Process.killProcess(android.os.Process.myPid());
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.face_button:
_canDraw = false;
try {
DrawThread.join();
whack.this.startActivity(selectFace);
} catch (InterruptedException e) {
e.printStackTrace();
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
I have an activity that keeps crashing onPause. Theres a looped thread that draws on a canvas. And When I paused the application or try to move to another activity it crashes.
I have it so it closes out onPause, because I don't want it to post a force close. But I want to be able to go back to the activity
@Override
public void surfaceDestroyed(SurfaceHolder arg0) {
// TODO Auto-generated method stub
boolean retry = true;
_canDraw = false;
while(retry) {
try {
DrawThread.join();
retry = false;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
android.os.Process.killProcess(android.os.Process.myPid());
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
android.os.Process.killProcess(android.os.Process.myPid());
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.face_button:
_canDraw = false;
try {
DrawThread.join();
whack.this.startActivity(selectFace);
} catch (InterruptedException e) {
e.printStackTrace();
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想知道为什么它会在暂停时崩溃吗?你正在破坏它。
You're wondering why it crashes onPause? You're crashing it.