在登录后的onSuccess块中,我正在初始化我的领域配置,然后创建一个User对象。
if (SyncUser.currentUser() != null) {
RealmConfig.form = new SyncConfiguration.Builder(SyncUser.currentUser(), getString(R.string.form)).name("form.realm").build();
RealmConfig.user = new SyncConfiguration.Builder(SyncUser.currentUser(), getString(R.string.user)).name("user.realm").build();
RealmConfig.userObjects = new SyncConfiguration.Builder(SyncUser.currentUser(), getString(R.string.user_objects))
.name("userObjects.realm")
.waitForInitialRemoteData()
.build();
}
Realm.getInstanceAsync(RealmConfig.userObjects, new Realm.Callback() {
@Override
public void onSuccess(Realm realm) {
User user = realm.where(User.class).equalTo("id",
SyncUser.currentUser().getIdentity()).findFirst();
if (user == null) {
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
User user = realm.createObject(User.class, UUID.randomUUID().toString());
user.setEmail(mEmailView.getText().toString().trim());
}
});
// go to CreateUserName
} else {
// go to Dashboard
Intent intent = new Intent(getBaseContext(), MainActivity.class);
intent.putExtra("isAdmin", isAdmin);
getBaseContext().startActivity(intent);
}
}
});
我无法打开我想要创建用户的实例,因为这次崩溃...另外我收到错误说" RealmException:在后台线程中初始化Realm时发生异常。"
答案 0 :(得分:0)
WOW。好的,所以我一直在打击"输入"在我的笔记本电脑的键盘上,它快速连续两次调用登录功能,并且必须将其搞砸。我点击了"登录"实际屏幕上的按钮,它没有问题。
有时除了你自己之外没有人可以责备......