Reputation: 509
I have an application that per user action to open a URL, opens a URL with ad and after a few seconds opens the URL requested by the user. Due to the need to run inside a Titanium module, I cannot open a webview, so I open the default browser (code below) twice. Once with the ad and once with the URL. Now, if the user wants to get back to the ad, he cannot do it with the BACK button as this one closes the browser and shows the previous activity. (this is the code:)
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
Then, if one clicks on the BACK button he gets back to the previous activity. I would like to make the BACK button go to the previous browser URL. Is there a way to make it happen?
Thanks, Simon
Upvotes: 0
Views: 1027
Reputation: 5145
set one tag on the intent and whenever you press back then check tag on back press button OnBackPressed() and write the webview.goBack() on back press
@override
public void OnBackPressed()
{
webview.goBack();
}
Upvotes: 1
Reputation: 10553
If you want navigation in the webview to travel all the previous pages then you can put a back button and implement the navigation of the webview
using the method webview.goBack()
.
public void OnBackPressed()
{
your_webview.goBack().
}
Upvotes: 0