0

How to call a function only after opening an application?

I would like open custom function only after opening application.

Now I call this function in MainActivity. This is call after start, but if I go to other Activity and next back to MainActivity, then this function is recall.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    myFunction();
}

I don't want use BOOT_COMPLETED, because I want to it start only if I open my app.

ziwinuh
  • 9
  • 1
  • `Bundle savedInstanceState`. Only call your function when `savedInstanceState==null`. – greenapps Oct 17 '17 at 19:06
  • Well, personally I'd simply start the application with a different activity, do the initial stuff and then start the main activity. – karuhanga Oct 17 '17 at 19:08

0 Answers0