Currently supports String, Boolean, boolean, int, Integer.
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'
}
- 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);
}