i have a web view in my android app. it work fine in my phone .but when i test app in some other phone it dos not show anything until click on it.
this is my xml file:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_gravity="center"
android:orientation="vertical">
<ProgressBar
android:id="@+id/prog"
android:layout_width="320dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="true"
/>
<WebView
android:layout_width="320dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/webview"></WebView>
</LinearLayout>
and this is my web view client code for loading url:
private void startWebView(WebView webView,String url) {
webView.setWebViewClient(new WebViewClient() {
ProgressDialog progressDialog;
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
isRedirected = true;
return false;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
isRedirected = false;
}
public void onLoadResource (WebView view, String url) {
if(isOnline()) {
if (!isRedirected) {
mprogressbar.setVisibility(View.VISIBLE);
// if (progressDialog == null) {
// progressDialog = new ProgressDialog(MainActivity.this);
// progressDialog.setMessage("Loading...");
// progressDialog.show();
// }
}
}else{
//Toast.makeText(getApplicationContext(), "Internet is not avialable.Please check your connection!", Toast.LENGTH_LONG).show();
}
}
public void onPageFinished(WebView view, String url) {
try{
isRedirected=true;
mprogressbar.setVisibility(View.GONE);
// if (!progressDialog.isShowing()) {
// progressDialog.dismiss();
// progressDialog = null;
// }
}catch(Exception exception){
exception.printStackTrace();
}
}
});
webView.getSettings().setJavaScriptEnabled(true);
webView.loadData(url,"text/html", null);
}
please some body help. thank you