私の答えはNOです
なんで?
Android の Unhandled 例外の性質について理解しなければならない重要なことが 1 つあります。それはありません。Android では Uncaught 例外であり、「処理」したり、自分のように回復したりすることはできませんおそらく.Net環境ではそうでしょう。
Xamarin(Mono) は、文字通りすべてを try-catch で囲み、Unhandled イベントを発生させることで、キャッチされなかった例外を内部的に "処理" しますが、それは重要ではありません。また、さまざまな理由から、UI を操作することもお勧めできません。
理論的には、ユーザーにダイアログを表示したり、アプリを再起動したりするための「回避策」がいくつかありますが、どれもお勧めできません。代わりに、予想される例外を処理するために機密領域を try-catch 句で囲む必要があります。予期しない例外については、例外レポート コンポーネントを使用し、報告された例外を分析した後にアプリを更新するだけです。
からの説明
また、このようにアプリから未処理の例外をキャッチすることもできます
名前が ErrorActivityのようなベース アクティビティを作成します。
この例を見てください
protected override void OnCreate(Bundle bundle)
{
//register error handlers
AppDomain.CurrentDomain.UnhandledException += ErrorHandler.CurrentDomainOnUnhandledException;
TaskScheduler.UnobservedTaskException += ErrorHandler.TaskSchedulerOnUnobservedTaskException;
}
エラーハンドラクラス内
public static class ErrorHandler
{
/// <summary>
/// Tasks the scheduler on unobserved task exception.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="unobservedTaskExceptionEventArgs">
/// The <see cref="UnobservedTaskExceptionEventArgs" /> instance containing
/// the event data.
/// </param>
public static void TaskSchedulerOnUnobservedTaskException(object sender,
UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs)
{
var newExc = new Exception("TaskSchedulerOnUnobservedTaskException",
unobservedTaskExceptionEventArgs.Exception);
LogUnhandledException(newExc);
}
/// <summary>
/// Currents the domain on unhandled exception.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="unhandledExceptionEventArgs">
/// The <see cref="UnhandledExceptionEventArgs" /> instance containing the event
/// data.
/// </param>
public static void CurrentDomainOnUnhandledException(object sender,
UnhandledExceptionEventArgs unhandledExceptionEventArgs)
{
var newExc = new Exception("CurrentDomainOnUnhandledException",
unhandledExceptionEventArgs.ExceptionObject as Exception);
LogUnhandledException(newExc);
}
/// <summary>
/// Logs the unhandled exception.
/// </summary>
/// <param name="exception">The exception.</param>
internal static void LogUnhandledException(Exception exception)
{
try
{
string error =
$"Exception Caught:{DateTime.Now:F} The Error Message IS {exception.Message}\n\r full stack trace is {exception.ToString()} ";
#if DEBUG
const string errorFileName = "errorlog.txt";
var libraryPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
// iOS: Environment.SpecialFolder.Resources
var errorFilePath = System.IO.Path.Combine(libraryPath, errorFileName);
System.IO.File.WriteAllText(errorFilePath, error);
Android.Util.Log.Error("Crash Report error not handled", ex.ToString());
#else
// Log to Android Device Logging.
Android.Util.Log.Error("Crash Report", error);
#endif
}
catch (Exception ex)
{
Android.Util.Log.Error("Crash Report error not handled", ex.ToString());
// just suppress any error logging exceptions
}
}
}
これで、このように ErrorActivity からすべてのアクティビティを継承できます
Public class Fooactivity:ErrorActivity
{
}
これで、アプリでエラーを処理できます..だから、ログファイルからエラーログを取得します..またはAndroidデバイスのロギングモニター..これが役立つことを願っています...