So inside a IntentService, the app maybe active or inactive , onHandleIntent gets called , where I have placed this below code.This is where I store th
for (AppItem item : appItems) {
If appItems contains managed RealmObjects that you obtained from a RealmResults on the UI thread, then accessing them will fail on the background thread.
realm.executeTransactionAsync((realm) -> { gives you a Realm as parameter that is running on Realm's thread executor, so that must be used to obtain managed RealmResults/RealmObjects inside the transaction.
So you need to re-query the objects inside realm.executeTransactionAsync if the objects are managed.
public void execute(Realm realm) {
for (AppItem item : realm.where(AppItem.class).findAll()) {