Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Start MainActivity with different WebView loadUrl

 
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
Bartender
Posts: 3135
50
  • 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