×

Discussion Board

Results 1 to 3 of 3

Thread: DeviceControl

  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Austria
    Posts
    86

    DeviceControl

    Hi!

    In the document "Guidelines for game developers v2.0" nokia says that the existence of the DeviceControl class (flashlight, vibra) should be checked using a Class.forName("com.nokia.mid.ui.DeviceControl") construct.
    But if this class does not exist (like in the nokia s60 concept sdk), i can't use it, and i have to put comments around calls to the DeviceControl class.
    If i compile my jar file using a sdk that includes the class, and want to run this jar file on a device without this class, i get a verification error.

    Can anyone tell me how i can check the existence of flashlight and vibra support ?

    Thanks
    McMc

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    393
    Put the Class.forName(..) in a try/catch block. If the class in the parameter does not exist then a ClassNotFoundException is thrown. The whole idea is to check for existence of the class before using it.

    try {
    Class.forName(“com.nokia.mid.ui.DeviceControl”);
    }
    catch(ClassNotFoundException e) {
    // Can’t use vibration because of the API is not supported in the device
    }


    [N]/Forum Nokia

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Austria
    Posts
    86
    Hi!

    Thanks for reply. I will try to compile my game with a sdk that has the class and then i will run it on the s60 concept.

    Thanks
    McMc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •