2
ちょっとみんなを発生し、その中の例外のクラスやメソッド名を取得する方法、それは私が以下のようなメソッドを持っているアプリケーションクラスアンドロイドは - それは私が中心的な場所で私のAndroidアプリ内のすべての例外を処理したい
です私のアプリケーションクラスで:
public void HandleException(Exception e)
{
String appName = getString(R.string.app_name);
String className = ""; // magic method to find out the original class name where the exception occurred
String methodName = ""; // magic method to find out the original method name where the exception occurred
Log.e(appName, className + " : " + methodName + " - " + e.getMessage());
}
すべてのことが今欠けているが、例外が
を発生し、その中の元クラスとメソッドで私のクラス名とmethodNameの変数を移入する魔法の方法は、誰もが
を助けることができるです事前のおかげで...
あなたのパッケージ名でクラス名を検索しています - どのクラスでも例外が発生する可能性があるため、検索するクラス名を知るには... – Raj
あなたのクラス名にはパッケージ名が含まれている必要があります'com.raj.application'で検索します。 'if(element.getClassName()。contains(yourPackageName))){//あなたのクラスです}' – ernazm