I tried including the relevant bit. I’m new at this and working with existing code. I hope someone can point me in the right direction.
Basically, say my website is http://www.mywebsite.com (lets call this ‘A’ since I can only post two hyperlinks) and you decide to do a search, so now the URL looks like this:
http://www.mywebsite.com/?s=notes (call it ‘B’)
You then get the SearchPage activity with the search results. Now say I tap a link from the search results. Example:
the url above/category/easy-news/ (call it ‘C’)
Website ‘C’ should load in PageActivity (which it does) but still loads up in SearchPageActivity which was initially showing ‘B’.
On top of all of that, there seems to be a 3rd PageActivity (though it doesn’t look like it opens a third time). One that also loads ‘C’ again. As mentioned, it is still the PageActivity, though. Pressing back closes the PageActivity and shows another PageActicity with the URL ‘C’.
Closing that a second time takes me back to SearchPageActivity with the same URL ‘C’ which was initially ‘B’. Pressing back one more time takes me back to ‘B’ within the same activity.
I don’t seem to have this issue with the MainActivity, only in the SearchPage activity. In the MainActivity, things work fine. The code below is from SearchPage activity.
Sorry for the long winded message. I hope someone can help. Thanks.
Thanks.
private boolean isAppOrGamePage(String paramString) {
if ((paramString == null)
|| paramString.length() < 24
|| (!paramString.substring(0, 24).equals(
"http://www.mywebsite.com")))
return false;
String str1 = paramString.substring(24);
String str2 = str1.substring(0, 1 + str1.indexOf('/', 2));
if ((!mAppIdentifiers.contains(str2))
&& (!mGameIdentifiers.contains(str2)))
return false;
return true;
}
public boolean shouldOverrideUrlLoading(WebView paramWebView,
String paramString) {
if (MainActivity.DEBUG)
Log.e("shouldOverride", paramString);
if (Uri.parse(paramString).getHost() != null
&& (!Uri.parse(paramString).getHost()
.equals("myspace.com"))
&& (!paramString.contains("facebook.com"))
&& (!Uri.parse(paramString).getHost()
.contains("twitter.com"))
&& (!Uri.parse(paramString).getHost()
.equals("goo.gl"))
&& (!Uri.parse(paramString).getHost().contains("bit.ly"))
&& (!Uri.parse(paramString).getHost()
.contains("plus.google.com"))
&& (!Uri.parse(paramString).getHost()
.contains("youtube.com")))
if (isAppOrGamePage(paramString)) {
final Intent intent = new Intent(SearchActivity.this,
PageActivity.class);
intent.putExtra("app_url", paramString);
startActivity(intent);
} else
return false;
return false;
}
}
Return true when you open the other activity. You need to consume that call.
Returning true tells the webview that you have handled it, and don’t want it to do anything with it.