Protects against calling methods on wrong threads using AspectJ and Android's
@MainThread
/@WorkerThread
annotations.
Set up AspectA as described here: https://github.com/serso/aspecta.
Import Thread Guard library to your project:
dependencies {
implementation 'org.solovyev.android.threadguard:lib:1.0.2'
}
Optionally, you can specify how to penalize the violations:
package org.example.android;
class App extends Application {
@Override
void onCreate() {
ThreadGuard.penaltyDeath();
// or
ThreadGuard.penaltyLog();
}
}