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.
精彩评论