DGBootstrap is the library that includes the four basic libraries of the Digipolitan framework, DGFoundation, DGSQL, DGSQLite and DGNetwork. He is made to allow you to develop an application using all our non GUI features (Dependency injection, cache repositories, model factories etc…)

It automatically configure the DependencyInjectorManager to allow the use of SQLite and some other features like the UsageManager (to execute a tast at the first launch or every x launches)

This sample’s purpose is to show you the different steps to create a simple app using DGBootstrap and be ready for your project development.


Android Studio


We will create the two main classes defining an Android application, the Application and the Activity and configure the manifest.
Here is a screenshot of our project structure

Getting started Android

Including dependencies

You need to declare the Digipolitan maven repository to be able to resolve maven dependencies. Simply declare it in your project build.gradle file :

allprojects {
	repositories {
		maven {
			url '' 

And declare a dependency for DGBootstrap in your app module :

dependencies {
	compile ''
	compile 'com.digipolitan.libraries:DGBootstrap:1.0'

Here the sample requires appcompat-v7 and DGBootstrap.

Creating the Application

The Application object is the shared Context of your application code, you can override some methods to customize it

public class Application extends AbstractApplication{

	protected void bootstrap() {
		// here you can add your own modules to the dependency manager
	protected void rebootApplication() {
		//called when app is restored from background since getResetDuration() you can tell your restored activity to do some stuff via getCurrentActivity()
	public long getResetDuration() {
		//you need to override this method to specify the duration(in millis) the app needs to be in background to be reset
		return (long) (DateUtils.MINUTE_TIME_IN_MILLIS * 2.5);

Creating the Activity

You need to override DGAbstractActivity, to be sure that the Application is notified of the current Activity displayed.

public class MainActivity extends DGAbstractActivity {

	protected void onCreate(Bundle savedInstanceState) {
		LogManager.d("Activity Created!");
	protected int getLayoutRes() {
		return R.layout.activity_main;

Configuring the manifest

Now we need to configure the manifest to declare our application, activity and set the environment

<manifest xmlns:android=""
package="com.digipolitan.libraries.bootstrap.bootstrapsample" >
	android:theme="@style/AppTheme" >
		<meta-data android:name="" android:value="@string/environment_type_debug"></meta-data>
			android:label="@string/app_name" >
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />

If you launch the app you should see an entry in the LogCat :

  com.digipolitan.libraries.bootstrap.bootstrapsample D/[MainActivity][onCreate:14]﹕ Activity Created!