aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "how to avoid force close dialog?" Watch "how to avoid force close dialog?" New topic
Author

how to avoid force close dialog?

Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
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

Joined: Jan 08, 2009
Posts: 1477
    
    6

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


Swastik
zoheb hassan
Ranch Hand

Joined: Apr 01, 2009
Posts: 153

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

Regards,
Zoheb
thomas brian
Greenhorn

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 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);
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to avoid force close dialog?