Robert
Robert

Reputation: 337

Android Load WebView Url from main activity

I'm new one at Android Developing so maybe this question will be quite easy but I was unable to find answer.

On main activity that is loaded just after app goes run I display splash screen with app logo. On another activity that is displayed after splash screen is hided I have webview and load some url for example http://www.google.com.

Generaly when I change activity to this one with webview page is loading.

My question is how to start loading page in another activity when splash screen is displayed.

It is possible to access webview object in main activity and run webview.loadUrl?

Thanks for help

Upvotes: 2

Views: 547

Answers (1)

Brian
Brian

Reputation: 8085

What you can do in this situation is actually make the activity that has the WebView as your launching activity. That is, change the manifest declaration to have your WebView activity be the starting activity. Then inside your WebView activity, use startActivity(...) at the end of your onCreate to launch your splash screen. This should happen fast enough that there will almost be no perceivable effects. Finally, when you're ready to close your splash screen all you have to do is just call finish() and you will return to your WebView activity.

Upvotes: 1

Related Questions