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
Developer
Posts: 27
Registered: ‎12-23-2008
My Device: 10000
My Carrier: Developer

get a Screen Instace

How I can get a Screen was instaced, can I get it?, I've a list of results and if you clicK in a especific record this do a specific request and open a new screen, if you go back return to the result list.

 

I mean that can i have a "Vector" of screens or stored the screens?, only instance one time and store this in array o vector and when you will need the screen get it from array.

 

Thanks.

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

Re: get a Screen Instace

your english is very hard to understand, it would be great if you could use a spell checker of sorts to make it a bit understandable.

internally screens are stored in a lifo container, you can show the last screen by calling popScreen, for example.

you can store references to the screens however you want, be it a vector or an array. ask yourself if you really need this though, it will be a source for a multitude of errors and, if you reference many screens, a performance or memory issue.
----------------------------------------------------------
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
Developer
Posts: 27
Registered: ‎12-23-2008
My Device: 10000
My Carrier: Developer

Re: get a Screen Instace

Thanks and excuse my English language, but each screen request information from the server and i would

like make a request only once, so i need get a screen has already been instantiated and show it to user

and no repeat the same request all the time.

Developer
Posts: 27
Registered: ‎12-23-2008
My Device: 10000
My Carrier: Developer

Re: get a Screen Instace

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

Re: get a Screen Instance

I suggest you review the following Threads:

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=14734

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=10240

 

There are many possible ways of doing what you are trying to do.  To help make this discussion easier to follow, let us focus on just one way and explain the issues with it.

 

You can keep a Vector of all the Screens you have created, and then choose to display one of these rather than recreate it. 

 

However there is a potential problem.  The usual way of going from one screen to another on the Blackberry is to PUSH the new screen on to the Display stack, so that it covers up the preceding screen.  Then, when the user has finished with a screen, you POP that screen off the stack, exposing the one below. 

 

But screens can only appear once on the Display Stack.  So say, you get Screen A from the Server and display it.  Then you get Screen B and display it.  Then the user asks for Screen C, so you get it as well.  Now, if you have used standard BB processing you will have A, B and C on the Display Stack.  But now the user wants Screen A again.  You can't just push your saved Screen A, because it is already on the Display Stack.

 

So if you want to do this, then you should pop the current screen and push the replacement screen, at the same time, so you don't have a hierarchy of screens.  But this makes it difficult for the user to go 'Back' (like you can in a Browser for example).

 

The other problem is the overhead of keeping all the Screens in memory.

 

Instead of doing this, you could retain the details that the Server has sent you, from which you create the Screen.  Then you don't have to get the details again from the Server (which is going to take a long time), instead you can just recreate the screen.

 

Hope this is clear.

Developer
Posts: 27
Registered: ‎12-23-2008
My Device: 10000
My Carrier: Developer

Re: get a Screen Instance

"Instead of doing this, you could retain the details that the Server has sent you, from which you create the Screen.  Then you don't have to get the details again from the Server (which is going to take a long time), instead you can just recreate the screen."
"retain the details that the Server has sent you" --- > Data Vector -->Vector 1

 

Lot of thanks peter but i would comment that I need to store in a vector1 : text and images extracted from server . It is posible? -- (overhead of memory) --
How much images (.gif) can I allocate in this vector1?, what do you suggest? or is preferable only store text in the vector1?

And another point .. this vector1 will grow because will store another vector2 that is a conversation thread  -- dinamically generated for the user (lot of messages [300 characters per message])  --
what do you suggest?, what is the most effective?
1.- request to server data (text and images) every time user need the screen
or
2.- get data (text and images) only once and store it in a vector1 and allow this grow with the vector2 (conversation thread)  and images?

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

Re: get a Screen Instance

text does not need much memory, no problem about having it twice.
pictures on the other hand do need some space. but: retrieving pictures from the net needs traffic which is even more valuable.
i would not suggest to store really large amounts of images, but a few kilobytes make no real difference.

be reminded of java being an object oriented language. if you have a bitmap object your vector does not copy the bitmap when you put it into the vector, it just stores a reference. if you put the bitmap into a bitmapfield and display it on the screen the same bitmap object is used.
if you "store" something in a vector you are actually only referencing it!
----------------------------------------------------------
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
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: get a Screen Instance

Simon's comments are absolutely spot on.  Thanks Simon.

 

Just to add, you can do some rough calculations to determine the space that is required by the data you are passing round.  These are just rough and based on my observations, not on any actual RIM published data:

 

a) For a String of text, which is an Object, you need to double the number of characters and then add 100 for the Object reference, and that will let you know how many bytes of storage each String will take.  So a String with 300 characters needs about 700 bytes.

 

b) For the image, you can store the bytes of data that are sent down from the Server.  If you do it this way, then you know the Server size in bytes, so add 100 bytes for the Object reference overhead.

 

Finally to confirm Simon's comment, that "retrieving pictures is even more valuable", consider the following.  In some testing I did on GPRS, sending a picture took about 1 second for each 1K bytes, so is slow.  In addition it uses up the battery (network traffic does this).

Developer
Posts: 27
Registered: ‎12-23-2008
My Device: 10000
My Carrier: Developer

Re: get a Screen Instance

Thaks a lot peter and simon Smiley Happy, this will help me.