Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9102099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:17:50+00:00 2026-06-17T01:17:50+00:00

I am doing an Android application that takes the HTML code of a website.

  • 0

I am doing an Android application that takes the HTML code of a website. I got a Webview that should load this HTML but when I run my program, I don’t see my “HTML”.

Here is my code:

    package com.example.getdonnees;

import android.app.Activity;

import android.os.Bundle;

import android.webkit.WebView;

public class MainActivity extends Activity {

    WebView webview;

    Web web = new Web();

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        webview = (WebView)findViewById(R.id.webView1);

        webview.getSettings().setJavaScriptEnabled(true);

                try {

                    webview.loadData(web.getCode(), "text/html; charset=UTF-8", null);
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

    }


}



    package com.example.getdonnees;

import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.net.URL;

import java.net.URLConnection;

import android.app.Activity;

import android.os.Bundle;

import android.webkit.WebView;

public class Web extends Activity {

    WebView webview;
    String s2 = "";

    public String getCode() throws Exception{
        URL oracle = new URL("http://www.google.com/");
        URLConnection yc = oracle.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        String s1 = "";
        while ((inputLine = in.readLine()) != null)
            s1 = s1 + inputLine;
        in.close();
        System.out.println(s1);
        s2 = "<h1> test </h1>";
        return s1;
    }

}

If I put webview.loadData("<h1> Test </h1>", "text/html; charset=UTF-8", null); it works
If I return s2 in getCode(), it doesn’t work.
And naturally, if I return s1, it doesn’t work.

I discovered this part crashes the app. Do you know why ?

            try {
            in = new BufferedReader(new InputStreamReader(
                                        yc.getInputStream()));
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:17:51+00:00Added an answer on June 17, 2026 at 1:17 am

    TRy like this..

    import android.app.Activity;
        import android.os.Bundle;
        import android.view.View;
        import android.webkit.WebSettings;
        import android.webkit.WebView;
        import android.webkit.WebViewClient;
    
        public class AndroidMobileAppSampleActivity extends Activity {
            /** Called when the activity is first created. */
            @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
    
                WebView mainWebView = (WebView) findViewById(R.id.mainWebView);
    
                WebSettings webSettings = mainWebView.getSettings();
                webSettings.setJavaScriptEnabled(true);
    
                mainWebView.setWebViewClient(new MyCustomWebViewClient());
                mainWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    
                mainWebView.loadUrl("http://seasonofrejoice.blogspot.com");
            }
    
            private class MyCustomWebViewClient extends WebViewClient {
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    view.loadUrl(url);
                    return true;
                }
            }
        }
    

    Add the xml webview..

    <WebView android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/mainWebView">
     </WebView>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an android application that hits the WebView and displays the content. But
I am currently doing an android application that contains customize alert dialog. It contains
Now i am doing an android application.In that application I am using asynchtask class
Am doing a simple android application.In that I am deleting an element from array
I am developing an Android application that uses a WebView pointed at a jQueryMobile-based
I'm new in android developement. I'm doing an application that will go through some
I am doing an contact list android application but i have a small problem
I have an android application that was working great but 2 days ago things
I'm developing an Android application that makes a Query using Activity.managedQuery() , which takes
So I'm making this android application, that needs to read data from user-provided CSV

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.