| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
opensrp-core is the core Android library that powers OpenSRP-based mobile clients, providing shared sync, data, and UI infrastructure for implementers.
Groovy DSL:
repositories {
mavenCentral()
}
dependencies {
implementation 'io.github.bluecodesystems:opensrp-client-core:<version>'
}Kotlin DSL:
repositories {
mavenCentral()
}
dependencies {
implementation("io.github.bluecodesystems:opensrp-client-core:<version>")
}Replace <version> with the release published on the repository's Releases page (current tag: v7.0.0).
Call CoreLibrary.init from your Application to register sync configuration and optional peer-to-peer settings.
public final class CoreApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
SyncConfiguration syncConfig = new SampleSyncConfiguration();
CoreLibrary.init(this, syncConfig);
}
}public final class SampleSyncConfiguration extends SyncConfiguration {
@Override
public int getSyncMaxRetries() { return 3; }
@Override
public SyncFilter getSyncFilterParam() { return SyncFilter.PROVIDER; }
@Override
public String getSyncFilterValue() { return "demo-provider"; }
@Override
public int getUniqueIdSource() { return 1; }
@Override
public int getUniqueIdBatchSize() { return 250; }
@Override
public int getUniqueIdInitialBatchSize() { return 500; }
@Override
public SyncFilter getEncryptionParam() { return SyncFilter.TEAM_ID; }
@Override
public boolean updateClientDetailsTable() { return true; }
}// Access shared services and user/team context
org.smartregister.Context opensrpContext = CoreLibrary.getInstance().context();
AllSharedPreferences prefs = opensrpContext.allSharedPreferences();
String teamId = prefs.fetchDefaultTeamId(prefs.fetchRegisteredANM());// Persist synced clients/events in a batch
JSONArray events = /* build payload */;
JSONArray clients = /* build payload */;
ECSyncHelper syncHelper = ECSyncHelper.getInstance(this);
syncHelper.batchSave(events, clients);
syncHelper.updateLastSyncTimeStamp(System.currentTimeMillis());// Enable peer-to-peer sync with custom authorization
P2POptions options = new P2POptions(true);
options.setBatchSize(50);
options.setAuthorizationService(new MyAuthorizationService());
CoreLibrary.init(this, new SampleSyncConfiguration(), BuildConfig.BUILD_TIMESTAMP, options);Additional APIs live under org.smartregister.*; see class-level documentation for services, view fragments, and utilities.
A reference implementation lives in sample/.
Check the Releases page for published versions, changelog notes, and upgrade guidance.
Issues and pull requests are welcome. Before opening one:
Licensed under the Apache License, Version 2.0.
| Back | FazBrowse Home | New Git URL |