开发者

Back button in browser

From my application I use an Intent to open a web page in the Browser. The default behaviour is that back button leads to previous page in the browser and not back to my application. Is there a way to force the back button to return the user to my App?开发者_高级运维


Once you use an Intent to open into another app, it's up to that App to handle the back button. If you just want to show a webpage as an activity, you can run your own activity that hosts a WebView and use the following to open your web page:

webview.loadUrl("http://lolcats.com/");

And in your activity you can override the back button to do what you need to do:

@Override
public void onBackPressed()
{
    // put code here to do things
}


How are you calling the browser? If you do it like this:

Uri url = Uri.parse("http://mysite.com/");
Intent launchBrowser = new Intent(Intent.ACTION_VIEW, url);
startActivity(launchBrowser);

then it ought to work as you expect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜