如何给事件对强制关闭对话框的确定按钮 [英] How to give event on force close dialog's ok button
问题描述
您好我想知道,我该部队关闭对话框的确定按钮执行自己的操作?
Hi I want to know can I perform my own operations on Force Close Dialog's OK Button ?
推荐答案
恐怕你不能这样做。反倒是你能避免强制关闭使用未捕获的异常处理程序。
I am afraid you can't do that. But rather you can avoid force close by using uncaught Exception handler.
这些链接可能会有所帮助。
These links might be helpful.
<一个href="http://www.java2s.com/Open-Source/Android/File/android-daisy3-reader/org/geometerplus/zlibrary/ui/android/library/UncaughtExceptionHandler.java.htm" rel="nofollow">http://www.java2s.com/Open-Source/Android/File/android-daisy3-reader/org/geometerplus/zlibrary/ui/android/library/UncaughtExceptionHandler.java.htm
的http://developer.android.com/reference/java/lang/Thread.UncaughtExceptionHandler.html
从上面的链接样本片断,
A sample snippet from the above link,
public class UncaughtExceptionHandler 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, BugReportActivity.class);
intent.putExtra(BugReportActivity.STACKTRACE, stackTrace.toString());
myContext.startActivity(intent);
Process.killProcess(Process.myPid());
System.exit(10);
}
}
这篇关于如何给事件对强制关闭对话框的确定按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!