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

  • SEARCH
  • Home
  • 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 8308255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:45:05+00:00 2026-06-08T18:45:05+00:00

Im trying to show an image in an webview but my app crashes as

  • 0

Im trying to show an image in an webview but my app crashes as soon as it gets to the activity where the webview is loaded.

    WebView myWebView = (WebView) findViewById(R.id.webView1);
    myWebView.getSettings().setJavaScriptEnabled(true);
 //   myWebView.getSettings().setBuiltInZoomControls(true);
 //   myWebView.getSettings().setSupportZoom(true);
    myWebView.loadUrl("http://www.de-saksen.nl/2/images/comprofiler/62_4dc3051f2b262.jpg");
 //     myWebView.loadData(
 //            "<img src='http://www.de-saksen.nl/2/images/comprofiler/62_4dc3051f2b262.jpg'>",
 //            "text/html", "UTF-8");

I’ve been puzzeling with the code a little but nothing helps.

The activity is in the Manifest.xml and it allows internet permission.

EDIT: Reading all of your awnsers helpt alot and noticed that the image loads if I place the code inside an new activity, but I need to be able to load it in this one:

public class Profileviewer extends ListActivity {


/** Called when the activity is first created. */

 @Override
 public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);


    setContentView(R.layout.listplaceholder);


    ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();


    JSONObject json = JSONfunctions.getJSONfromURL("http://de-saksen.nl/deelnemers.txt");



    try{

        JSONArray  deelnemers = json.getJSONArray("deelnemers");

        int Key = getIntent().getIntExtra("Key", -1);

            { HashMap<String, String> map = new HashMap<String, String>();  
            JSONObject e = deelnemers.getJSONObject(Key);

            map.put("id",  String.valueOf(Key));
            map.put("name", "Naam: " +  e.getString("naamingw2"));
            map.put("sex", "Geslacht: " +  e.getString("geslacht"));
            map.put("rank", "Rang: " +  e.getString("rang"));
            map.put("race", "Ras: " +  e.getString("ras"));
            map.put("profession", "Beroep: " +  e.getString("beroep"));
            map.put("skills", "Hobby's: " +  e.getString("hobbys"));
            map.put("lvl", "Level: " +  e.getString("level"));
            map.put("avatar", e.getString("avatar"));
            mylist.add(map);            
        }   



    }catch(JSONException e)        {
         Log.e("log_tag", "Error parsing data "+e.toString());
    }

    ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.profile, 
                    new String[] { "name", "sex", "rank", "race", "profession", "skills", "lvl" }, 
                    new int[] { R.id.item_title, R.id.item_subtitle, R.id.item_subtitle2, R.id.item_subtitle3, R.id.item_subtitle4, R.id.item_subtitle5, R.id.item_subtitle6 });

    setListAdapter(adapter);




    final ListView lv = getListView();
    lv.setTextFilterEnabled(true);  
    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {              
            Intent intent = new Intent(Profileviewer.this, Listviewer.class);   
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
            startActivity(intent); 
        }
    });



}
}

Because in this activity I have the current selected user.

  • 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-08T18:45:06+00:00Added an answer on June 8, 2026 at 6:45 pm

    use this

    byte[] imageRaw = null;
    try {
     URL url = new URL("http://some.domain.tld/somePicture.jpg");
     HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
    
     InputStream in = new BufferedInputStream(urlConnection.getInputStream());
     ByteArrayOutputStream out = new ByteArrayOutputStream();
    
     int c;
     while ((c = in.read()) != -1) {
         out.write(c);
     }
     out.flush();
    
     imageRaw = out.toByteArray();
    
     urlConnection.disconnect();
     in.close();
     out.close();
     } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     }
    
      String image64 = Base64.encodeToString(imageRaw, Base64.DEFAULT);
    
      String urlStr   = "http://example.com/my.jpg";
      String mimeType = "text/html";
      String encoding = null;
      String pageData = "<img src=\"data:image/jpeg;base64," + image64 + "\" />";
    
      WebView wv;
      wv = (WebView) findViewById(R.id.webview);
      wv.loadDataWithBaseURL(urlStr, pageData, mimeType, encoding, urlStr);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to show profile Contact image from SQLite on android app but it
I am trying to show a histogram for a image in jlabel, but its
I'm trying to show an image on my Image control but it isn't working.
I'm trying to show image from DB saved in Image field. But I can
I am trying to show an image in a grid view through a handler.But
So, I am trying to have this image show up in the fancy box
First I'm going to show you an image of what I'm trying to recreate
This is the code I have. I'm trying to insert a image to show
The following image have been uploaded to show what I am trying to do
I'm trying to make an image appear on top of another and still show

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.