I want to convert the following API code to Java Reflection code. Need help in converting it
Actual ANRWatchDog code :
private void initWatchDog() {
ANRWatchDog watchDog = new ANRWatchDog(5000);
watchDog.setIgnoreDebugger(true);
watchDog.setANRListener(new ANRWatchDog.ANRListener() {
@Override
public void onAppNotResponding(ANRError anrError) {
if(anrError != null) {
FileUtils.saveToFile(anrError.getMessage());
Tracer.d(TAG, anrError.getMessage());
}
}
});
}
As for now, I'm able to progress till here :
private void invokeANRWatchDog() {
try {
Class anrWatchDog = Class.forName("com.github.anrwatchdog.ANRWatchDog");
Object anrWatchDogObj = anrWatchDog.getConstructor(Integer.class).newInstance(5000);
Method anrIgnoreDebugger = anrWatchDog.getMethod("setIgnoreDebugger", Boolean.class);
anrIgnoreDebugger.invoke(anrWatchDogObj, true);
} catch (Exception e) {
Tracer.d(TAG, e.getMessage());
}
}
Now I'm stuck up in converting the below listener callback code for ANR WatchDog:
watchDog.setANRListener(new ANRWatchDog.ANRListener() {
@Override
public void onAppNotResponding(ANRError anrError) {
if(anrError != null) {
FileUtils.saveToFile(anrError.getMessage());
Tracer.d(TAG, anrError.getMessage());
}
}
});
Please help me in converting above code to Java Reflection.
Aucun commentaire:
Enregistrer un commentaire