• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Start MainActivity with different WebView loadUrl

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic