import net.rim.device.api.system.ApplicationDescriptor; import net.rim.device.api.system.ApplicationManager; import net.rim.device.api.system.ApplicationManagerException; import net.rim.device.api.system.CodeModuleManager; import net.rim.device.api.ui.MenuItem; import net.rim.device.api.ui.component.Menu; import net.rim.device.api.ui.container.MainScreen; import net.rim.device.api.system.Bitmap; public class MyScreen extends MainScreen { private static final MenuItem menuItemClose = new MenuItem( "Close", 13, 244) { public void run() { System.exit(0); } }; private static final MenuItem menuItemRun = new MenuItem( "Run", 13, 244) { public void run() { int handle = CodeModuleManager .getModuleHandle("net_rim_bb_file_explorer"); if (handle <= 0) { System.out.println("HANDLE IS INVALID"); return; } ApplicationDescriptor[] appDescriptors = CodeModuleManager .getApplicationDescriptors(handle); if ((appDescriptors==null) || (appDescriptors.length == 0)) { System.out.println("App descriptors are missing"); return; } String[] args = {"", "" }; ApplicationDescriptor descriptor = new ApplicationDescriptor( appDescriptors[0], "Media explorer", args, Bitmap.getBitmapResource("icon.png"), -1, null, -1, ApplicationDescriptor.FLAG_SYSTEM); try { ApplicationManager.getApplicationManager().runApplication(descriptor); } catch (ApplicationManagerException e) { System.out.println("App cannot be launched"); System.out.println(e.getMessage()); return; } } }; public MyScreen() { super(); } public boolean onClose() { System.exit(0); return false; } public void makeMenu(Menu menu, int context) { menu.add(menuItemRun); menu.add(menuItemClose); } } |
No comments:
Post a Comment
Place your comments here...