realm android update notification, android - RealmChangeListener is not called when Realm is updated in NotificationListenerService...

I am expanding

Realm insertion on NotificationListenerService as follows:

public class NLService extends NotificationListenerService {

@Override

public void onNotificationPosted(StatusBarNotification sbn) {

// building realmObject here

mRealm = Realm.getDefaultInstance();

RealmHelper.saveObj(myRealmObject, mRealm);

// mRealm.waitForChange(); / mRealm.refresh();

mRealm.close();

}

}

public class RealmHelper {

public static RealmModel saveObj(RealmObject realmObject, Realm realm) {

realm.beginTransaction();

RealmObject newRealmObject = realm.copyToRealm(realmObject);

realm.commitTransaction();

return newRealmObject;

}

}

With Realm newer than v0.88.3, ​​the single RealmChangeListener(rcl) will not be called if anything is inserted in the NLService.

I tried attaching rcl directly to Realm, RealmResults and RealmObject, nothing works.

该应用程序具有例如RealmResults< myRealmObject> .size()的简单rcl和

永远不会调用几个RecyclerAdapter和RealmRecyclerViewAdapter中的rcl.

然而,重新运行查询起作用并且显示“缺失数据”.

此外,如果在ui-或任何其他线程上插入了任何内容,则会调用rcl并显示“缺少数据”.

我在Realm 0.88.3上呆了好几个月,因为我无法使用任何更新的Realm版本.用0.88.3 mRealm.refresh();在NLService中被调用,这在新版本中不可用,并且.waitForChange无休止地阻塞.

的Manifest.xml:

android:name=".service.NLService"

android:label="@string/nl_service"

android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324174484&siteId=291194637