Skip to content

Latest commit

 

History

History
70 lines (55 loc) · 1.18 KB

README.md

File metadata and controls

70 lines (55 loc) · 1.18 KB

This is still in progress, it can break at anytime.

Currently supports String, Boolean, boolean, int, Integer.

Usage:

Step 1


android{...}
repositories {
	maven {
    	url "https://jitpack.io"
	}
}

Step 2


android{...}
buildscript {
	repositories {
		mavenCentral()
    }
	dependencies {
		classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
	}
}
apply plugin: 'com.neenbedankt.android-apt'

Step 3


android{...}
dependencies {
	apt 'com.github.shrikanthkr:saveinstance-processor:v0.0.3'
	compile 'com.github.shrikanthkr:saveinstance-api:-SNAPSHOT'
}

Sample

  • In your activity code

@SaveInstance
String hello;
  • OnCreate Method

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	if(savedInstanceState != null) {
		Retainer.load(this, savedInstanceState);
	}
}
  • OnSaveInstanceState Method

@Override
protected void onSaveInstanceState(Bundle outState) {
	super.onSaveInstanceState(outState);
	Retainer.save(this, outState);
}