Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to avoid force close dialog?

 
Suzzane Pinto
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i want to avoid showing the force close popup whenever app gets crashed...
iam trying not to get force close but still if any dnt want dat irritating dialog.....an dalso that my app ahud exit after force close,it should not go back to any activity.....that gives so many errors again....
please help
thankyou
 
Swastik Dey
Rancher
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Foreclose usually happens when there is any uncaught exception in you code. So you should handle exceptions properly.
 
zoheb hassan
Ranch Hand
Posts: 154
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check Your Logcat, it's bound to show what's going wrong there

Regards,
Zoheb
 
thomas brian
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To make such kind of mechanism we need to make one error handler and an Activity class which will gain the view whenever the app gets forced closed.

import java.io.*;

import android.content.*;
import android.os.Process;

public class ExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler {
private final Context myContext;

public UncaughtExceptionHandler(Context context) {
myContext = context;
}

public void uncaughtException(Thread thread, Throwable exception) {
StringWriter stackTrace = new StringWriter();
exception.printStackTrace(new PrintWriter(stackTrace));
System.err.println(stackTrace);

Intent intent = new Intent(myContext, CrashActivity.class);
intent.putExtra(BugReportActivity.STACKTRACE, stackTrace.toString());
myContext.startActivity(intent);

Process.killProcess(Process.myPid());
System.exit(10);
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic