开发者

Calling Activity from WebView on shouldOverrideUrlLoading()

In webview, I click a link that 开发者_如何学Pythontakes me to an activity through following code :

public boolean shouldOverrideUrlLoading(WebView view, String url) {
        // TODO Auto-generated method stub
        if(url.equals("factory.cpp")){
            Toast.makeText(getApplicationContext(), "Clicked on link", Toast.LENGTH_SHORT).show() ;
            Intent intent = new Intent(getApplicationContext(), FactoryCppFiles.class) ;
            startActivity(intent) ;
            return false ;
        }
        else
            return true ;
    }

The FactoryCppFiles activity is displayed properly, but when I press the back button, it shows me the following standard error message.

Web page not available

I want to show the web view where I clicked on the link. How do I achieve this?


Just realized I should return true if I want to handle the URL myself. I switched the return statements and it works fine now.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜