我有一个 android 应用程序,我在内部依赖几个库。现在我正在尝试记录在单个组件级别(这意味着单个库级别)发生的崩溃,以便帮助我分析导致崩溃的组件。
public class MyApplication extends Application implements Thread.UncaughtExceptionHandler {
public static final String TAG = "myapplication";
public static MyApplication applicationInstance;
public MyApplication() {
Thread.setDefaultUncaughtExceptionHandler(this);
}
@Override
public Context getApplicationContext() {
return super.getApplicationContext();
}
public static MyApplication getInstance() {
return applicationInstance;
}
@Override
public void onTerminate() {
super.onTerminate();
}
@Override
public void onLowMemory() {
super.onLowMemory();
}
@Override
public void onTrimMemory(int level) {
super.onTrimMemory(level);
}
@Override
public void uncaughtException(Thread t, Throwable e) {
Log.i(TAG, "Inside uncaught exception..." + Thread.currentThread().getId());
//getPackageName() here returns the name of the application instead of the dependent library's one.
}
}
有什么方法可以获取在他们的 android 清单中添加的库的包名称?