So I have a custom webView that seems to be great for the single url that is needed for my application. I tested the same URL in my tablet’s native browser and it loads fine, but in my user web view it freezes when it downloads forever. other urls work fine with my webview. I have a webSetting suite for plugins, so I don't think this is a problem. I noticed that the screen starts to spin up as soon as the page loads, and then immediately disappears.
my webview:
public class Browser extends Activity {
private WebView wv;
private ProgressDialog progressBar;
private static final String TAG = "Browser";
private SharedPreferences prefs;
private String prefName = Constants.prefName;
private static final String TABLET_TYPE_KEY = Constants.TABLET_TYPE_KEY;
private String tabletType;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
prefs = getSharedPreferences(prefName, MODE_PRIVATE);
tabletType = prefs.getString(TABLET_TYPE_KEY, "");
boolean customerTablet = false;
boolean associateTablet = false;
boolean doctorTablet = false;
boolean doctorDoctorTablet = false;
if(tabletType.equals("Associate")) {
associateTablet = true;
}
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
String url = "";
String navtype = "";
Bundle extras = getIntent().getExtras();
if(extras != null) {
url = extras.getString("url");
navtype = extras.getString("navtype");
}
if(navtype.equals("nonav")) {
setContentView(R.layout.browsernonav);
}
else {
setContentView(R.layout.browser);
}
wv = (WebView) findViewById(R.id.webview1);
wv.setWebViewClient(new Callback());
WebSettings webSettings = wv.getSettings();
webSettings.setBuiltInZoomControls(true);
webSettings.setJavaScriptEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setPluginsEnabled(true);
webSettings.setPluginState(WebSettings.PluginState.ON);
if(associateTablet) webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
wv.addJavascriptInterface(new JavaScriptInterface(this), "Android");
progressBar = ProgressDialog.show(Browser.this, "", "Loading...");
final Browser MyActivity = this;
if(!navtype.equals("nonav")) {
final ImageView btn_back = (ImageView) findViewById(R.id.btn_back);
btn_back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
wv.goBack();
}
});
final ImageView btn_forward = (ImageView) findViewById(R.id.btn_forward);
btn_forward.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
wv.goForward();
}
});
}
wv.loadUrl(url);
}
private class Callback extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return(true);
}
@Override
public void onPageFinished(WebView view, String url) {
Log.i(TAG, "Finished loading URL: " +url);
if (progressBar.isShowing()) {
progressBar.dismiss();
}
}
@Override
public void onPageStarted (WebView view, String url, Bitmap favicon) {
progressBar = ProgressDialog.show(Browser.this, "", "Loading...");
}
}
public class JavaScriptInterface {
Context mContext;
JavaScriptInterface(Context c) {
mContext = c;
}
public void spawnPrintJob() {
Uri uri = Uri.parse("file:///sdcard/medical_form.html");
Intent i = new Intent(Intent.ACTION_VIEW);
i.setPackage("com.dynamixsoftware.printershare");
i.setDataAndType(uri, "text/html");
startActivity(i);
}
public void deleteForm() {
File sdCard = Environment.getExternalStorageDirectory();
File[] toBeDeleted = sdCard.listFiles(new FileFilter() {
public boolean accept(File theFile) {
if (theFile.isFile()) {
return theFile.getName().endsWith(".html");
}
return false;
}
});
for(File deletableFile:toBeDeleted){
deletableFile.delete();
}
}
}
}
again the url loads fine in a normal browser ...
source
share