Categories: Java | Java ME | How To | Code Examples | Base/System
This page was last modified 09:47, 28 November 2007.
How to detect if a Class/Package is available on the phone
From Forum Nokia Wiki
You know Java ME has many optional packages that phones must have preinstalled over MIDP and CLDC. So, how can you compile one only code that detects on the fly if some class or API is available?
We can use the dynamic instantiation method, like this:
boolean MMAPIAvailable; try { // Try to instantiate a class using a string as the Class name // so, the SDK without the API can compile the application Class.forName("javax.microedition.media.Player").newInstance(); // If the next code is executed, then the API is available MMAPIAvailable = true; } catch ( ClassNotFoundException e) { MMAPIAvailable = false; }
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| I'm having a bit of trouble with java | wiz1705 | Mobile Java General | 1 | 2006-07-31 10:07 |
| How to detect series? | kdermpan | General Discussion | 0 | 2003-12-01 05:55 |
| Using Startup List Management API | kiranpuranik | General Symbian C++ | 6 | 2006-09-21 09:27 |
| help:我安装了s60 2nd fp3 midp sdk,在eclipse下运行出错 | squarefw | Other Programming Discussion 关于其他编程技术的讨论 | 5 | 2007-02-28 09:26 |
| How to organize j2me classes into packages? | Aresibo | Mobile Java Tools & SDKs | 2 | 2008-06-01 10:25 |
