1. covaks's Avatar
    I've been messing around with the Blackberry JDE and there's something I don't understand. I know this is probably going to sound stupid, but..

    I've been trying to learn by drawing things on the screen and then do stuff with it (ie, move boxes and circles around, etc, simple stuff). I was using Graphics.getScreenWidth/Height() to get the dimensions of the display. I saw somewhere that someone said to use "Display.getWidth/Height()" instead because the first way is deprecated.

    When I do that, the JDE tells me "Reference to class: net.rim.device.api.system.Display requires signing with key:"

    So, here come the stupid questions.

    If something is deprecated, does that mean in future releases it will no longer work? Or is there a big advantage to using Display.getWidth() over Graphics.getScreenWidth(), and that's the only reason it's suggested?

    I assume there are other ways to get the width/height of the display(?). With no disadvantages to Display.getWidth/Height(), but then what am I missing about this method that requires it to be signed?

    There's a voice in the back of my tiny little head saying to me: "Wait a minute, at some point down the road, am I going to be expected to sign my app for 100 bucks, for something so simple as getting the width/height of the display?" I know I must be missing something here.
    01-06-09 08:53 PM
  2. patrick.waugh's Avatar
    If something is deprecated, does that mean in future releases it will no longer work? Or is there a big advantage to using Display.getWidth() over Graphics.getScreenWidth(), and that's the only reason it's suggested?
    It does indeed mean that it will eventually not be supported by a new version of the API.


    I assume there are other ways to get the width/height of the display(?). With no disadvantages to Display.getWidth/Height(), but then what am I missing about this method that requires it to be signed?
    The only other way of determining the screen dimensions would be to determine the device model and infer them from this information. However, those classes also require code signatures as I recall.

    While you might not consider it much of an "advantage", the shift of these methods occurred from the Graphics class to the Display class as width and height are attributes of a "display", and not of a Graphics context. So, they are now more properly encapsulated which also makes the API easier to use and understand.

    The class has likely been designated as a "secured" class as it allows software to perform a screen capture, something which could be very bad if it were done without a users knowledge, like if classified information where secretly captured this way and then secretly emailed by the app. Or imagine how embarrassed some guys would be when the program their wife gave them secretly emailed her screen captures of your phone book or copies of the pictures they are viewing at lunch.


    There's a voice in the back of my tiny little head saying to me: "Wait a minute, at some point down the road, am I going to be expected to sign my app for 100 bucks, for something so simple as getting the width/height of the display?" I know I must be missing something here.
    You are.

    Although the use of the Display class method does require a code signing key for use on an actual device, you can either:

    a) Continue to compile against an API version (4.6 or below) which does support it
    b) Use the new method, but do your experiments on a simulator (does not required sigs)
    c) Get a key for $20 from RIM

    and you are not paying for it so you can merely get the width and height, you are paying for it to help RIM offset the cost of managing them so that if someone puts out mal-ware, RIM can promptly revoke their code signature to prevent them from distributing any further software. In other words, you are paying so that we as a community can be protected, something RIM is known for providing (unlike say Microsoft).

    Hope this answers your question.
    01-07-09 04:53 AM
LINK TO POST COPIED TO CLIPBOARD