This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 213
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: 1449

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: 150

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());

subject: how to avoid force close dialog?
Similar Threads
public Dialog(Frame owner, boolean modal) not working as expected
invoking dialog box from Applet results in Hang of IE browser
Printing a file
Thread got stuck?
Jdialog issue