Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Posts: 70
Registered: ‎04-14-2010
My Device: bold 9000
My Carrier: new

application is not responding; pocess termonated

[ Edited ]

i have searched a few post ,but i cant find solution

 

in my case

i made UI to be re-painted by invokelater

 

in re-paint function,

program get bitmap-data through network and re-paint it by swap

i think Since the connection is blocking, the program's event queu will fill up

 

original-webbitmapfield not match my case

so my modified-webBitmapField function does not have thread

 

when i change speed getting image from server by thread.sleep()

sometime "application is not responding; pocess termonated" is popup and

my program killed

 

what wrong with my network source ?

 

 

-main

{

          Thread.Start(every 1seconds)

}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

BitmapField newField,swapField,oldField;

-in re-paint func

{

       getData();   < ----- get bitmap through network

    

    newField.setImage(bitmap);        //swap field to be re-painted
                   swapField = newField;  
                   newField = oldField;
                   oldField = swapField;

 

}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

-in Thread func

            UiApplication.getUiApplication().invokeLater(
                  new Runnable(){
                    public void run(){
                        infoscreen. re-paint func
}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

    public boolean getBitmap(String url)<-------i think the program's event queu will fill up
    {
        int length = 0;        
        
        responseData = new byte[100000];
              try{
                 connection = (HttpConnection) Connector.open(url  + ";deviceside=true", Connector.READ_WRITE, true );
                 int responseCode = connection.getResponseCode();
                     if (responseCode != HttpConnection.HTTP_OK){
                           requestFailed("Unexpected response code: " + responseCode);
                            connection.close();
                            bRet = false;
                            return bRet;
                    }
                     
                 inputStream = connection.openInputStream(); //Open and return an input stream for a connection.
             
                 
                 StringBuffer rawResponse = new StringBuffer();
                 try{
                 while (-1 != (length = inputStream.read(responseData)))  
                {
                    rawResponse.append(new String(responseData, 0, length));
                }
                 }catch(Exception e){
                     bRet = false;
                     return bRet;
                     }
                 
                final String result = rawResponse.toString();
                dataArray = result.getBytes();
           
                try{
                    bitmap = EncodedImage.createEncodedImage(dataArray, 0, dataArray.length);
                  
                    bitmapfromEncoded = bitmap.getBitmap();
                             
                }catch(IllegalArgumentException iae){
                    String str = "the image format is not recognized";
                    System.err.println(str);
                    bRet = false;
                    return bRet;
                }
                     
                inputStream.close();
                inputStream = null;
                connection.close();
                connection = null;
    
                return bRet;
 
              }catch(final IOException ex){
                 requestFailed(ex.toString() );
                bRet = false;
                return bRet;
                }
    }//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: application is not responding; process terminated

You can't run blocking code on the Event Thread.  In this case you are attempting to download the image on the Event Thread, and what you see is the result. 

 

I don't know webBitmapField very well, but I suspect the Thread you removed in webBitmapField was there for a reason, to stop this sort of problem.  I think you will have to put it back. 

 

The usual way around this sort of issue is to display a place holder image until the real image has been downloaded. 

Regular Contributor
Posts: 70
Registered: ‎04-14-2010
My Device: bold 9000
My Carrier: new

Re: application is not responding; process terminated

[ Edited ]

 

 

 

i have to use ui to be repainted by invoker

but  webBitmapField makes thread

 

if  my-WebBitmapField have thread,  there are thread problem

 

" one-program only have maximum 16 thread"

 

so i did delete WebBitmapField-thread

 

is it your opinion that the probelm is "re-paint " ?

i think my problem is network

 

i tested  some case

if i comment on the "re-paint"  there are errors           //repaint

if i comment on the "network "  there are no errors  //getBitmap

 

Developer
Posts: 16,984
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: application is not responding; process terminated

if you want to download that many pictures concurrently you need to implement a command queue. google it, its a developer pattern.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter