WebView on Android by modifying HTML

3

I'm able to load the URL on my device using WebView , but the page you're uploading is not mobile-friendly. I would like to know if I have access to the page, however, by deleting some parts of HTML. Code below:

MainActivity.java:

public class MainActivity extends ActionBarActivity {

Button btEntrar;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final WebView myWebView = (WebView) findViewById(R.id.webView1);

WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);

myWebView.setWebViewClient(new WebViewClient());

myWebView.loadUrl("SITE");

btEntrar = (Button) findViewById(R.id.btEntrar);
}


private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if (Uri.parse(url).getHost().equals("SITE DESEJADO")) {
        // This is my web site, so do not override; let my WebView load the page
        return false;
    }
    // Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    startActivity(intent);
    return true;
}
}

I want to leave only the login field, password and login button, and then move on normally.

    
asked by anonymous 02.11.2014 / 21:33

1 answer

1

You can use the loadData method. To learn more about the loadData method and also other methods that can be used in your case, see documentation .

Example usage:

webview.loadUrl("http://example.com/");

String example = "<html><body>My first body<b>LIKE</b> mee.</body></html>";
webview.loadData(example, "text/html", null);
  • Sample code available in documentation.

Hugs.

    
03.11.2014 / 04:17