I'm working on the development and refactoring of some Activity's
that has similar behaviors in our projects, so to avoid code repetitions, for common functionalities, I've created some Activity's
base, which are inherited by the other Activity's. >
My problem is this, since what I am creating is class
base ), which can be used by several others, I need to ensure that whoever uses it will use it, correct it. Therefore, I would like to check for nonconformities in the% base% parameters and to cast a class
if there are nonconformities, so that these errors are caught in the development and testing phase.
This does not seem to be possible, here's what you'd like to do:
@Override
protected void onCreate(Bundle savedInstanceState) {
userHelper = new UserHelper(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.container_for_fragment);
if (savedInstanceState == null) {
if (mFragment != null) {
getFragmentManager().beginTransaction()
.add(R.id.container, mFragment).commit();
}else{
// essa linha não compila: "Unhandled exception type Exception"
throw new Exception("mFragment, deve ser setado antes da chamada do onCreate() da class base \"ListAbstractActivity\"");
}
}
}
Questions