• Post Reply Bookmark Topic Watch Topic
  • New Topic

Start MainActivity with different WebView loadUrl  RSS feed

 
Wavix John
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

In MainActivity I have this mWebView which changes loadUrl depending on the user action. I want this to happen from different class too.



and here is how I change loadUrl in MainActivity:



Now, in another class, ItemView, I want to switch to MainActivity but with different mWebView.loadUrl, depending on user action also. Hope you understand.

Here is what I tried in ItemView class:



This switch my app to MainActivity but everytime loadUrl is url1. url2 or url3 opens in system browser.

How can I fix this? I even tried to copy mWebView settings from the MainActivity, without success.

Thanks!
 
Tim Moores
Saloon Keeper
Posts: 3569
77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It takes a while for a new activity to start. In all likelihood, the code following startActivity will be executed before the activity has been started.

What you should do is to pass the URL along with the intent (see Intent.putExtra), and then let the main activity handle loading the URL.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!