Log saved instance size

This commit is contained in:
M66B 2019-04-11 09:47:49 +02:00
parent 9e4d3bb76a
commit 2a588443f2
3 changed files with 23 additions and 0 deletions

View File

@ -68,6 +68,16 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
super.onCreate(savedInstanceState);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
int before = Helper.getSize(outState);
super.onSaveInstanceState(outState);
int after = Helper.getSize(outState);
Log.i("Saved instance " + this + " size=" + before + "/" + after);
for (String key : outState.keySet())
Log.i("Saved " + key + "=" + outState.get(key));
}
@Override
protected void onResume() {
Log.i("Resume " + this.getClass().getName());

View File

@ -55,8 +55,14 @@ public class FragmentBase extends Fragment {
@Override
public void onSaveInstanceState(Bundle outState) {
Log.i("Save instance " + this);
int base = Helper.getSize(outState);
super.onSaveInstanceState(outState);
int before = Helper.getSize(outState);
outState.putString("fair:subtitle", subtitle);
int after = Helper.getSize(outState);
Log.i("Saved instance " + this + " base=" + base + " size=" + before + "/" + after);
for (String key : outState.keySet())
Log.i("Saved " + key + "=" + outState.get(key));
}
@Override

View File

@ -42,6 +42,7 @@ import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.PowerManager;
import android.text.TextUtils;
import android.view.Display;
@ -1153,4 +1154,10 @@ public class Helper {
return organization;
}
}
static int getSize(Bundle bundle) {
Parcel p = Parcel.obtain();
bundle.writeToParcel(p, 0);
return p.dataSize();
}
}