Image won't load

All your problems with Audio, Video and Images.

Image won't load

Postby korndi » Mon Aug 30, 2010 3:23 pm

Hi my prog wont download the image.
please help me
Code: Select all
package com.example;

import java.io.InputStream;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class example extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        final Button bt = (Button)this.findViewById(R.id.Button01);
        bt.setOnClickListener(new OnClickListener() {
         
         public void onClick(View v) {
            bt.setVisibility(4);
              Bitmap bmImg;
             ImageView iv = (ImageView)example.this.findViewById(R.id.ImageView01);
             URL imgurl = null;
             try
             {
                imgurl = new URL("http://androidwizard.net/wp-content/woo_uploads/3-androidheadertest.png");
             }
             catch (Exception e) {
               // TODO: handle exception
            }
              try
              {
                 HttpsURLConnection conn = (HttpsURLConnection) imgurl.openConnection();
                 conn.setDoInput(true);
                 conn.connect();
                 int length = conn.getContentLength();
                 InputStream is = conn.getInputStream();
                 bmImg = BitmapFactory.decodeStream(is);
                 iv.setImageBitmap(bmImg);

              }
              catch (Exception e) {
               // TODO: handle exception
            }
         }
      });

    }

}
korndi
Freshman
Freshman
 
Posts: 4
Joined: Mon Aug 30, 2010 3:14 pm

Top

Re: Image won't load

Postby jonbonazza » Mon Aug 30, 2010 7:03 pm

First off, add some type of handling for your exceptions so that you can see exactly where it is going bad.

Have you done any debugging at all?
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Re: Image won't load

Postby korndi » Mon Aug 30, 2010 7:49 pm

i debugg on my phone and the phone don't show the picture
korndi
Freshman
Freshman
 
Posts: 4
Joined: Mon Aug 30, 2010 3:14 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 19 guests