You Are Here:

Community: Developer Discussion Boards

#1 Old platform portability - 2003-08-13, 17:28

Join Date: Apr 2003
Posts: 184
zivgr
Offline
Regular Contributor
I wrote a MIDlet that uses JSR-120 functionality among other things. When I run it on a phone that doesn't support JSR-120 I get an error message for known reasons.
However, I want be able to run this code on a non-JSR120 phone while disabling the WMA(JSR-120) functionality.
In other words, I want to be able to run the same code on a variety of devices and be able to detect in run time which functionality is not supported and just not use it.
Reply With Quote

#2 Old 2003-08-13, 17:37

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
Taken from the Nokia block game example:
Code:
    private GameEffects makeGameEffects()
    {
        try
        {
            Class.forName("com.nokia.mid.sound.Sound");
            Class.forName("com.nokia.mid.ui.DeviceControl");

            // If no exception was thrown, use the vendor-specific APIs.
            Class clas = Class.forName("NokiaGameEffects");
            return (GameEffects) clas.newInstance();
        }
        catch (Exception e)
        {
            // The vendor-specific APIs are not available,
            // so use the 'stub' GameEffects instead.
            return new GameEffects();
        }
    }
You can use the same approach for any other optional API.

shmoove
Reply With Quote

#3 Old 2003-08-13, 17:42

Join Date: Apr 2003
Posts: 184
zivgr
Offline
Regular Contributor
But shouldn't I also put an import statement at the beginning of the class
Reply With Quote

#4 Old 2003-08-13, 17:55

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
No. You are using Class.forName() so you shouldn't need it.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia