问题
I am wondering how would a Google play is capable of capturing list of errors occuring in the applications it has and showing it to the developer?
Backdrop: We are trying to replicate an application like Google store? We should maintain a list of enterprise application through our application. We wanted to implement an exception capturing framework through our application that is capable of capturing exception by our list of apps and show and store it in backend.
回答1:
I assume Android applications are tied to Google Play market so that when exceptions occurs, the crash report to be sent to them.
One possible solution would be to let your users implement some kind of library in order to publish apps on your market. That library should do nothing but catch exceptions and send crash reports to your servers (something like ACRA).
Though, as a developer, I don't think this approach is one good, unless you offer something very promising to developers (like app visibility, promotion, etc)
回答2:
I do not know how Google Play does it, but for my needs I create my own java.lang.Thread.UncaughtExceptionHandler
:
class MyUncaughtExceptionHandler implements UncaughtExceptionHandler {
private UncaughtExceptionHandler mDefaultUncaughtExceptionHandler;
MyUncaughtExceptionHandler() {
mDefaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
}
@Override
public void uncaughtException(Thread aThread, Throwable aThrowable) {
// do your stuff
mDefaultUncaughtExceptionHandler.uncaughtException(aThread, aThrowable);
}
}
And register it in android.app.Application#onCreate
.
@Override
public void onCreate() {
super.onCreate();
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler());
}
来源:https://stackoverflow.com/questions/15565926/how-does-google-play-capture-exceptions-from-our-mobile