use of io.realm.internal.network.NetworkStateReceiver in project realm-java by realm.
the class SyncObjectServerFacade method init.
@Override
public void init(Context context) {
//noinspection TryWithIdenticalCatches
try {
// FIXME: Reflection can be avoided by moving some functions of SyncManager and ObjectServer out of public
Class<?> syncManager = Class.forName("io.realm.ObjectServer");
Method method = syncManager.getDeclaredMethod("init", Context.class);
method.setAccessible(true);
method.invoke(null, context);
} catch (NoSuchMethodException e) {
throw new RealmException("Could not initialize the Realm Object Server", e);
} catch (InvocationTargetException e) {
throw new RealmException("Could not initialize the Realm Object Server", e);
} catch (IllegalAccessException e) {
throw new RealmException("Could not initialize the Realm Object Server", e);
} catch (ClassNotFoundException e) {
throw new RealmException("Could not initialize the Realm Object Server", e);
}
if (applicationContext == null) {
applicationContext = context;
applicationContext.registerReceiver(new NetworkStateReceiver(), new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
}
Aggregations