outofmemoryerror

70 views
Skip to first unread message

Popoola Ife

unread,
Jul 25, 2013, 2:28:15 PM7/25/13
to codenameone...@googlegroups.com
  NetworkManager manage = NetworkManager.getInstance();
         
manage.addProgressListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                NetworkEvent e = (NetworkEvent)evt;
                       
                System.err.println(e.getProgressPercentage());
             
                if(e.getProgressPercentage() == 100){
                      FileSystemStorage a = FileSystemStorage.getInstance();
              
                System.out.print("saving");
                    try {
                        byte[] file = download.getResponseData();
                        System.out.println(listdownload.filepath.elementAt(0));
                        a.openOutputStream(listdownload.filepath.elementAt(0).toString() + "/"+ listdownload.listtodownloadname.elementAt(current).toString() +".mp3").write(file);
                      
                    } catch (IOException ex) {
                        ex.printStackTrace();
                    }
                }
               
            }
        });
        manage.addToQueueAndWait(download);


Anytime i try to download a large file i get an outofmemory error and something about the heapspace but when i download a small file it works well.  My question is ow do i solve the outofmemory error when i download a large file

My second question is how do i carry out simulteanous connection request that is open more than connectionrequest and they would be working side by side

I hope you understand Thank YOU

Shai Almog

unread,
Jul 26, 2013, 12:10:58 AM7/26/13
to codenameone...@googlegroups.com
Hi,
the progress listener is meant to follow progress for progress indication not for downloading.
If you want to download large files you shouldn't use a listener but instead derive the connection request and override the readResponse method where you can just write the stream to any place you want. This will remove the need of allocating an array in the size of the file.

Popoola Ife

unread,
Jul 29, 2013, 10:34:25 AM7/29/13
to codenameone...@googlegroups.com
but please okay i stop using the progress listener and i can download large files now but how to i determine d download percentage bcos i was uing progresslistener to get download percentage . AND PLEASE MY CRITICAL PROBLEM IS THE NETWORK MANAGER WHILE DOWNLOADING A FILE I NEED TO OPEN ANODA CONNECTION REQUEST SO PLEASE HOW DO I OPEN TWO CONNECTION REQUESTS SIMULTANEOUSLY



--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/iXiCmI3-QP0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/dd2a78c3-c5c2-48ab-a53c-76441c295d13%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Popoola Ife

unread,
Jul 29, 2013, 12:22:32 PM7/29/13
to codenameone...@googlegroups.com
thank you

Shai Almog

unread,
Jul 29, 2013, 12:47:24 PM7/29/13
to codenameone...@googlegroups.com
You can still use the progress listener to monitor progress which is what its designed to do. Its just really bad for performing the actual download.

Popoola Ife

unread,
Aug 5, 2013, 8:48:40 AM8/5/13
to codenameone...@googlegroups.com
thanx for all your replies.

but please i need your help again
can you please tell me how i can stream songs with codenameone just like
the player in j2me which u can use to stream an inputstream

and secondly ow can i minimize a codenameone app when the user closes the app

THANK YOU i would be expecting your reply



On Mon, Jul 29, 2013 at 5:47 PM, Shai Almog <shai....@gmail.com> wrote:
You can still use the progress listener to monitor progress which is what its designed to do. Its just really bad for performing the actual download.

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/iXiCmI3-QP0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.

Shai Almog

unread,
Aug 5, 2013, 2:00:54 PM8/5/13
to codenameone...@googlegroups.com
You should open separate threads for separate questions. Close buttons don't exist on most devices so minimize is the default for most platforms but we don't provide much control over that.

Media allows you to play from InputStream but notice that most device won't work well with that, J2ME was actually pretty amazing in its capabilities there! Android to this day still can't do media as well as J2ME in some regards.
Reply all
Reply to author
Forward
0 new messages