java - How to call a method only when the app has been launched? Please see details -
i have method in i'm fetching user's details , data firebase
database.
the problem method getting called twice or thrice after launching app , again when i'm navigating other activity.
i have put method in oncreate
method this:
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); checkauthstate(); }
i sure haven't called checkauthstate()
in onstart()
or onresume()
methods.
this how i'm navigating other activity:
@override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case android.r.id.home: onbackpressed(); return true; } return super.onoptionsitemselected(item); }
please let me know why checkauthstate()
getting called thrice , why getting called again when navigating other activity , how call method once when app has been launched?
sorry if question seems badly formatted. i'm still beginner!
create launcher activity checkauthstatus. start new activity , kill launcher activity.
Comments
Post a Comment