We can also add custom properties in the .jad file. Am also explaining how to read custom properties.
In my application, I added a custom property of APP-URL in .jad file. It contains a URL and the opens the Blackberry browser with this url.
You need to test this application on the device only, when try to test on simulator the CodeModuleGroupManager.loadAll(); will return you null.
The following is the sample code of how to read the default(modulename) and custom (APP-URL) properties of the .jad file.
package com.winit.webicon;
import java.util.Enumeration;
import net.rim.blackberry.api.browser.Browser;
import net.rim.blackberry.api.browser.BrowserSession;
import net.rim.device.api.system.Application;
import net.rim.device.api.system.ApplicationDescriptor;
import net.rim.device.api.system.CodeModuleGroup;
import net.rim.device.api.system.CodeModuleGroupManager;
public class MainClass extends Application
{
private BrowserSession bs;
private static String defaultURL = "http://www.google.com";
public static void main(String[] args)
{
if( args != null && args.length > 0)
defaultURL = args[0];
new MainClass();
}
MainClass()
{
bs = Browser.getDefaultSession();
CodeModuleGroup[] allGroups = CodeModuleGroupManager.loadAll();
CodeModuleGroup myGroup = null;
String moduleName = ApplicationDescriptor.currentApplicationDescriptor().getModuleName();
for (int i = 0; i < mygroup =" allGroups[i];" defaulturl =" myGroup.getProperty(" defaulturl ="=" e =" myGroup.getPropertyNames();" jad ="">" + e.toString());
while(e.hasMoreElements()){
System.out.println(e.nextElement().toString());
}
}
}
else
{
System.out.println("Server URL: myGroup NOT found !");
}
}
catch (NullPointerException e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
System.out.println("BBGov: MainClass: Constructor: URL: " + defaultURL + "\n");
bs.displayPage(defaultURL);
bs.showBrowser();
}
}
The following is the smaple .jad file
Manifest-Version: 1.0
RIM-COD-Module-Name: BBGov
RIM-COD-Module-Dependencies: net_rim_cldc,net_rim_bbapi_browser
MIDlet-Jar-Size: 17860
MIDlet-1: ,,
RIM-COD-Creation-Time: 1270629011
MIDlet-Jar-URL: BBGov.jar
RIM-COD-URL: BBGov.cod
RIM-COD-SHA1: 67 b4 bf 32 bc f1 d1 a2 40 b1 bb 9c 78 c0 0c b5 0d 10 e3 f5
RIM-COD-Size: 15308
MicroEdition-Configuration: CLDC-1.1
APP-URL: http://www.winitsoftware.com
MIDlet-Version: 0.0
MIDlet-Name: BBGov
MIDlet-Vendor:
MicroEdition-Profile: MIDP-2.0
RIM-MIDlet-Flags-1: 0
No comments:
Post a Comment