Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I check if the webview searchterm is valid before loading the url?
    text
    copied!<p>I am trying to load a webview using a search term. So, say the searchterm entered in the search box is "abcnews" it will load the url (<a href="http://server.com/something/" rel="nofollow">http://server.com/something/</a>"+searchterm+"%20something) as (<a href="http://server.com/something/abcnews/something" rel="nofollow">http://server.com/something/abcnews/something</a>) But suppose if the searchterm doesnt exist, say I load something like "whatever", for which <a href="http://server.com/something/whatever/something" rel="nofollow">http://server.com/something/whatever/something</a> is invalid I want the page to redirect to another page within my app (say relatedsearch view). How do I go about the same? Here's my code for the same so far: In searchtermfragment:</p> <pre><code> if((searchTerm.contains(mSearchView.getText().toString().toLowerCase() + " " + mSearchView.getText().toString().toLowerCase())))){ WebViewFragment frag = WebViewFragment.newInstanceForSearch(getFragmentManager(), searchTerm, null); frag.setSearchTerms(searchTerm); } else { RelatedSearchResultsFragment.newInstance(getFragmentManager(), searchTerm); } } </code></pre> <p>and in the search webview class I have:</p> <pre><code>if (environmentApi.equalsIgnoreCase(NetworkUtils.Apis.first)) { url = "https://mobile13.com/ms.0/fwd/service/v1/?q="+SearchTerm+"%20revenue&amp;ui.theme=novadark&amp;userAgent=android"; } </code></pre> <p>and in the oncreateview I have set the <code>webview.loadurl(url);</code> I am not sure where or how do I validate the searchterm to get the respective fragment accordingly if the searchterm is invalid( as the url doesnt switch either upon entering an invalid search term).Any clue on how to do the same?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload