You shouldn't really be overriding the constructor anyway. You should have a newInstance() static method defined and pass any parameters via arguments (bundle)
@Overridepublicvoid onCreate(Bundle savedInstanceState){
title = getArguments().getInt(EXTRA_TITLE);
message = getArguments().getString(EXTRA_MESSAGE);//...//etc//...}
Then you would instantiate from your fragment manager like so:
public onCreate(Bundle savedInstanceState){if(savedInstanceState ==null){
getSupportFragmentManager().beginTransaction().replace(R.id.content,AlertFragment.newInstance(
R.string.alert_title,"Oh noes an error occured!")).commit();}}
This way if detached and re-attached the object state can be stored through the arguments. Much like bundles attached to Intents.
You shouldn't really be overriding the constructor anyway. You should have a newInstance() static method defined and pass any parameters via arguments (bundle)
@Overridepublicvoid onCreate(Bundle savedInstanceState){
title = getArguments().getInt(EXTRA_TITLE);
message = getArguments().getString(EXTRA_MESSAGE);//...//etc//...}
Then you would instantiate from your fragment manager like so:
public onCreate(Bundle savedInstanceState){if(savedInstanceState ==null){
getSupportFragmentManager().beginTransaction().replace(R.id.content,AlertFragment.newInstance(
R.string.alert_title,"Oh noes an error occured!")).commit();}}
This way if detached and re-attached the object state can be stored through the arguments. Much like bundles attached to Intents.
http://stackoverflow.com/questions/10450348/do-fragments-really-need-an-empty-constructor?lq=1147down voteacceptedYes they do.You shouldn't really be overriding the con