I am getting error as The Web Page at file:///#/android_asset/webpage.htm could not be loaded as: Is a directory.
in the emulator.
but my code is webView.loadUrl("file:///android_asset/webpage.htm");
First the page renders perfectly but again after rendering refreshes the page and does not get loaded and will get the web page not available. If we could carefully see the url that has been given out by the android emulator there are two extra characters before android_asset.
Below is the code.
public class Catalog extends Activity {
final Activity activity = this;
WebView webView;
ProgressDialog progressDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);//used for rendering percentage of loading
setContentView(R.layout.catalog_layout);
try{
webView = (WebView) findViewById(R.id.browserwebview);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
activity.setTitle("Loading...");
activity.setProgressBarVisibility(true);
activity.setProgress(progress * 100);
if(progress == 100){
activity.setTitle(R.string.app_name);
}
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
Toast.makeText(activity, "Oh no!"+ description, Toast.LENGTH_SHORT).show();
}
@Override
public void onLoadResource (WebView view, String url) {
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
return true;
}
});
webView.loadUrl("file:/android_asset/web/webpage.html");
}
catch (Exception e) {
e.printStackTrace();
}
ImageButton btnBack = (ImageButton)this.findViewById(R.id.buttonBackCatalog);
btnBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(webView.canGoBack()){
webView.goBack();
}else{
Intent myIntent = new Intent(view.getContext(), FCFActivity.class);`
`startActivityForResult(myIntent, 0);
}
}
});
/*
* Actions for footer Buttons
*
*/
ImageButton buttonFooterMainHome = (ImageButton)findViewById(R.id.footerMainBtnHome);
buttonFooterMainHome.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), FCFActivity.class);
startActivityForResult(myIntent, 0);
}
});
LinearLayout homeLinearLayout=(LinearLayout)this.findViewById(R.id.footerLayoutHome);
homeLinearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), FCFActivity.class);
startActivityForResult(myIntent, 0);
}
});
}
@Override
public void onConfigurationChanged(final Configuration newConfig)
{
// Ignore orientation change to keep activity from restarting
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
}
}
}
Looking forward to your reply.
thanks.