Image from URL- works fine on WiFi but not on EDGE?

All your problems with Audio, Video and Images.

Image from URL- works fine on WiFi but not on EDGE?

Postby cousinHub » Thu Jan 14, 2010 9:40 am

This is working fine on a real device when I'm on Wifi, but does not work perfectly (from time to time an image is not diplayed?) when I'm on EDGE:
Does anyone has an idea WHY ?
Would you have an alternative solution to download an image from an URL ? Txs in advance.

ps: It's not always the same image that does not get downloaded ?

The logcat does not show any error. Only a warning :

"01-14 09:30:39.831: WARN/System.err(12156): Can't dispatch DDM chunk 46454154: no handler defined"

and

"01-14 09:30:49.691: INFO/global(12156): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required."

I tried
Code: Select all
BufferedInputStream bis = new BufferedInputStream(is, 8000);

or
Code: Select all
BufferedInputStream bis = new BufferedInputStream(is, 500000);

without any success :x


Code: Select all
public class Test extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        ((ImageView)findViewById(R.id.Map_1)).setImageBitmap(telechargerImage("http://www.meteobelgium.org/staticfiles/images/maps/today_a_AM_fr_5af8027cbbee4ee9d222438b2fd30dd3.gif"));
((ImageView)findViewById(R.id.Map_2)).setImageBitmap(telechargerImage("http://www.meteobelgium.org/staticfiles/images/maps/today_b_PM_fr_5af8027cbbee4ee9d222438b2fd30dd3.gif"));  ((ImageView)findViewById(R.id.Map_3)).setImageBitmap(telechargerImage("http://www.meteobelgium.org/staticfiles/images/maps/day_1__fr_870506d83cc7cb806dd35bfda2914b2e.gif"));  ((ImageView)findViewById(R.id.Map_4)).setImageBitmap(telechargerImage("http://www.meteobelgium.org/staticfiles/images/maps/day_2__fr_8a1688f3c1a55326ed80adf144ae89e3.gif"));
((ImageView)findViewById(R.id.Map_5)).setImageBitmap(telechargerImage("http://www.meteobelgium.org/staticfiles/images/maps/day_3__fr_f282eaaaf59a692cc07ba21ac6ed11ef.gif"));
       
    }
   
    public static Bitmap telechargerImage(String url) {
       Bitmap bm = null;
       try {
          Log.i("Hub","URL="+url);
          URL aURL = new URL(url);
          URLConnection conn = aURL.openConnection();
          conn.connect();
          InputStream is = conn.getInputStream();
          BufferedInputStream bis = new BufferedInputStream(is);
          bm = BitmapFactory.decodeStream(bis);
          bis.close();
          is.close();
       } catch (IOException e) {
          Log.e("Error","Error downloading the image: " + e.getMessage().toString());
       }
       return bm;
    }
}


XML :

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.    android:orientation="vertical"
  6.  
  7.    android:layout_width="fill_parent"
  8.  
  9.    android:layout_height="fill_parent"
  10.  
  11.    >
  12.  
  13. <TextView  
  14.  
  15.    android:layout_width="fill_parent"
  16.  
  17.    android:layout_height="wrap_content"
  18.  
  19.    android:text="@string/hello"
  20.  
  21.    />
  22.  
  23.    
  24.  
  25.                         <ScrollView android:layout_width="wrap_content"
  26.  
  27.                                                 android:layout_height="wrap_content">
  28.  
  29.                        
  30.  
  31.                         <LinearLayout android:orientation="vertical"
  32.  
  33.                                               android:layout_width="fill_parent"
  34.  
  35.                                               android:layout_height="fill_parent">
  36.  
  37.  
  38.  
  39.                         <ImageView      android:id="@+id/Map_1"
  40.  
  41.                                                 android:layout_height="wrap_content"
  42.  
  43.                                                 android:layout_width="fill_parent"
  44.  
  45.                                                 android:background="@drawable/icon"></ImageView>
  46.  
  47.                         <ImageView      android:id="@+id/Map_2"
  48.  
  49.                                                 android:layout_height="wrap_content"
  50.  
  51.                                                 android:layout_width="fill_parent"
  52.  
  53.                                                 android:background="@drawable/icon"></ImageView>
  54.  
  55.                        
  56.  
  57.                         <ImageView      android:id="@+id/Map_3"
  58.  
  59.                                                 android:layout_height="wrap_content"
  60.  
  61.                                                 android:layout_width="fill_parent"
  62.  
  63.                                                 android:background="@drawable/icon"></ImageView>
  64.  
  65.                         <ImageView      android:id="@+id/Map_4"
  66.  
  67.                                                 android:layout_height="wrap_content"
  68.  
  69.                                                 android:layout_width="fill_parent"
  70.  
  71.                                                 android:background="@drawable/icon"></ImageView>
  72.  
  73.                         <ImageView      android:id="@+id/Map_5"
  74.  
  75.                                                 android:layout_height="wrap_content"
  76.  
  77.                                                 android:layout_width="fill_parent"
  78.  
  79.                                                 android:background="@drawable/icon"></ImageView>
  80.  
  81.                        
  82.  
  83.                         </LinearLayout>                
  84.  
  85.                         </ScrollView>
  86.  
  87. </LinearLayout>
Parsed in 0.006 seconds, using GeSHi 1.0.8.4


MANIFEST
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.      package="com.cousinHub.Test"
  7.  
  8.      android:versionCode="1"
  9.  
  10.      android:versionName="1.0">
  11.  
  12.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  13.  
  14.         <activity android:name=".Test"
  15.  
  16.                  android:label="@string/app_name">
  17.  
  18.             <intent-filter>
  19.  
  20.                 <action android:name="android.intent.action.MAIN" />
  21.  
  22.                 <category android:name="android.intent.category.LAUNCHER" />
  23.  
  24.             </intent-filter>
  25.  
  26.         </activity>
  27.  
  28.  
  29.  
  30.     </application>
  31.  
  32.     <uses-sdk android:minSdkVersion="3" />
  33.  
  34.         <uses-permission android:name="android.permission.INTERNET" />
  35.  
  36. </manifest>
  37.  
  38.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4
User avatar
cousinHub
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sun Oct 04, 2009 7:26 am

Top

Postby cousinHub » Fri Jan 29, 2010 6:55 am

I am wondering if it's not because of the ScrollView ?

anyone is having the same kind of problem => an image not rendering when you're on a slow connection (EDGE), but works fine when you are on Wifi ?

please, HELP, as I can't see what else I should do to resolve the problem ...

What would you try ?
User avatar
cousinHub
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sun Oct 04, 2009 7:26 am

Re: Image from URL- works fine on WiFi but not on EDGE?

Postby csiku » Tue Mar 22, 2011 10:58 pm

Hi there!

DId you solved your problem successfully? Because I run into it, and I can't find any solutions for a week... :shock:
Please can you tell me what to do if my downloaded bitmaps are not shown? :( Please HELP!

Nora
csiku
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Mar 22, 2011 10:54 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Google Feedfetcher and 14 guests