-
Notifications
You must be signed in to change notification settings - Fork 18
DoJMA
Vikramaditya Kukreja edited this page Jan 29, 2017
·
4 revisions
This is the Application class where initialisation is done for external libraries
First indicate to the AndroidManifest.xml that this class is the Application class as shown here
<manifest
...>
<!-- permissions -->
<application
...
android:name=".DoJMA"
...>
...
</application>
</manifest>
External Libraries that are initialised here
LeakCanary
Firebase
Fresco
Realm
MutliDex
@Override
public void onCreate() {
super.onCreate();
//Attach the leak detector with this app
if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
return;
}
LeakCanary.install(this);
//Enable persistence in Firebase Database
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
//Keep data fresh
FirebaseDatabase.getInstance().getReference().keepSynced(true);
//Initialises the Fresco engine
Fresco.initialize(this);
//Initialise the relam database
//Name - from <a href="https://github.com/MobileApplicationsClub/DoJMA/wiki/utilities.DHC#constants">DHC Constants</a>
//Schema version depends on which version of the database we are at
//If schema version is different from the current version then delete the database
Realm.init(this);
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
.name(DHC.REALM_DOJMA_DATABASE)
.deleteRealmIfMigrationNeeded()
.schemaVersion(1)
.build();
Realm.setDefaultConfiguration(realmConfiguration);
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
//Install this apk using Multidex since the method count in this project exceeds the 64K limit
MultiDex.install(this);
}
Mobile Applications Club