I have an activity that starts a Java method from another class. In this class I start another activity that contains a WebView to read data from a Java Script website.
I use startactivity for this. But when I run startactivity it doesn't jump into OnCreate from the activity, but only at some point later. How can I start an activity and wait for it to be processed straight away?
It doesn't work with StartActivityForResult either.
Activityis starting as soon as possible always and never "immediatelly".Activitymust initialize itself and "sync" with system (its lifecycle), which takes time, few millis on fast devices, dozens and maybe even hundreds on weak unitsyou aren't helping using most heavy and inefficient compontent in system -
WebView. even more, you are executing JS in itmaybe some workaround would be to use single
Activityand switchingFragments. oneFragmentmay be native and visible on start (will be inited and rendered pretty fast), another may containWebViewand will be loaded onActivitys start, but invisible. insteadstartActivityyou may then switch visiblity ofFragments - one withWebViewis in fact already loaded in memory atActivitys start, should appear much faster