File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes how to avoid force close dialog? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "how to avoid force close dialog?" Watch "how to avoid force close dialog?" New topic

how to avoid force close dialog?

Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 214
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 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
Swastik Dey

Joined: Jan 08, 2009
Posts: 1579

Foreclose usually happens when there is any uncaught exception in you code. So you should handle exceptions properly.

zoheb hassan
Ranch Hand

Joined: Apr 01, 2009
Posts: 154

Check Your Logcat, it's bound to show what's going wrong there

thomas brian

Joined: Apr 19, 2012
Posts: 16
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 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));

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

I agree. Here's the link:
subject: how to avoid force close dialog?
It's not a secret anymore!