Considering I'm really new to Java, can you give me an example of how the
implementation should be done?

Thanks!

Ivan Soto Fernandez
Web Developer
http://ivansotof.com



On Wed, Jun 17, 2009 at 12:30 PM, Streets Of Boston <[email protected]
> wrote:

>
> Why do you create a byte-array (content)? If the wall-paper is big,
> you're using quite a bit of extra memory.
> If you want to be able to monitor download progress, wrap it inside
> your own implementation of an input-stream
>
>         URL url = new URL(address1);
>        HttpURLConnection uc = (HttpURLConnection) url.openConnection
> ();
>        InputStream is = (InputStream)uc.getContent();
>         int leng = uc.getContentLength();
>        MyProgressMonitorInputStream progressIS = new
> MyProgressMonitorInputStream(is, leng);
>        getApplicationContext().setWallpaper(progressIS);
>
> Then have MyProgressMonitorInputStream implement InputStream and
> update the progress in the 'read' methods
>
>
> On Jun 17, 11:54 am, Ivan Soto <[email protected]> wrote:
> > Hi, I'm trying to make my app display a download progress for bigger
> files.
> > But I can't figure how to make it work properly.The data is an image I
> plan
> > to set up as wallpaper
> >
> > Does anyone has an example of this?
> >
> > Thanks!!
> >
> >          URL url = new URL(address1);
> >
> >         HttpURLConnection uc = (HttpURLConnection) url.openConnection();
> >
> >         InputStream is = (InputStream)uc.getContent();
> >
> >         int progress = 0;
> >
> >         int leng = uc.getContentLength();
> >
> >         byte[] bytes = new byte[20480];
> >
> >         byte[] content = new byte[leng];
> >
> >         //starts reading the file
> >
> >         int readBytes = is.read(bytes);
> >
> >         while (readBytes > 0) {
> >
> >         readBytes = is.read(bytes);
> >
> >         progress += readBytes;
> >
> >         Log.d("d", progress +"");
> >
> >         }
> >
> >         ByteArrayInputStream bis = new ByteArrayInputStream(content);
> >
> >         getApplicationContext().setWallpaper(bis);
> >
> > Ivan Soto Fernandez
> > Web Developerhttp://ivansotof.com
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to