Android, Super not called exception error -


i have 2 fragments, myfirst fragment , mysecond fragment. mysecond fragment extends myfirst fragment.

classed this:

public class myfirstfragment extends fragment {         @override         public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {          ...                         }          @override         public void onactivitycreated(bundle savedinstancestate) {             super.onactivitycreated(savedinstancestate);         ...             // check view , map, request recreate if each of them null             if(myfirstfragment.this.getview() == null  ||  googlemap == null) {                 toast.maketext(getactivity().getapplicationcontext(), r.string.my_message, toast.length_long).show();                 return;             }         }     }  public class mysecondfragment extends myfirstfragment {         @override         public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {          ...         }          @override         public void onactivitycreated(bundle savedinstancestate) {             super.onactivitycreated(savedinstancestate);         ...         }     } 

my problem super.onactivitycreated(savedinstancestate); in onactivitycreated() method of mysecondfragment calls super. since want hide functionality of method in super class (which not useful fragment) have added onactivitycreated() method in mysecondfragment.

the problem if remove line have run-time error throws "supernotcalledexception".

what think? seems have extend fragment class instead of extending myfirstfragment. have variables in myfirstfragment need them in mysecondfragment.

you can write new function testfunction(bundle savedinstancestate) in myfirstfragment in call super.onactivitycreated(savedinstancestate);

and in mysecondfragment's onactivitycreated call testfunction(bundle savedinstancestate) rather super.onactivitycreated(savedinstancestate); i.e.

in myfirstfragment

testfunction(bundle savedinstancestate){     super.onactivitycreated(savedinstancestate); } 

in mysecondfragment

public void onactivitycreated(bundle savedinstancestate) {     super.testfunction(savedinstancestate); ... } 

i don't understand basic requirment bypass myfirstfragment's onactivitycreated can way.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -