Table of Contents: SRC
Description: According to the example code provided by rim, slightly modified:
1. Determine if network connectivity supports direct connections (the original code is to determine the MDS connection)
2. To determine the network connectivity situation is China Mobile/China Telecom/Unicom to take different APN cmnet 3gnet or use WAP 2.0 connection, according to the decision to use the corresponding network connection (the original code is using the MDS connection)
3. Remove the titlebar of the original code because the BlackBerry SDK 5.0 does not have a corresponding API
Table of Contents: Build.ota
File: A.jad codemoduleinstallersample.cod
Description: Compile a good installation program, when used, put the jad and cod files in the Apache website under any directory, mobile phone can be OTA installation
For the convenience of users OTA installation, Jad file name changed to A.jad
Table of Contents: Installersample
Here are three directories and a description file, Clorfultimeextracted,goonuu,networksample,applicationlist.txt
Description: In the program code and the next directory of multiple TXT files, hardcode the installation path to point to Http://shanghai.springworks.info/installerSample/applicationList.txt
Program source code Download bash here
Test program Download directly
After installation, click on the menu "Checkfor Update", wait a while, two programs are installed (Goonuu,colorfultime).
Note: These two programs after installation, you can directly click on the program icon to run, do not need to restart
==================================================================================
Postscript:
In program A with the API simple reinstall program A's cod file, will appear without prompting the user restart machine, the user does not unplug the battery board updated program A does not work.
So how does the program upgrade itself? The method is as follows:
Step 1: Delete yourself. (Plum blossom treasure, want to practice martial, the knife from the palace)
Step 2: Download the new version of the Cod file
Step 3: Install cod files
Original reference: http://blog.vimviv.com/blackberry/upgrade-application-blackbery/
public void Upgrade () {//delete it self.
int handle = Codemodulemanager.getmodulehandle (modulename);
if (handle!= 0) {int success = Codemodulemanager.deletemoduleex (handle, true);
SYSTEM.OUT.PRINTLN ("Response:" + success);
///Download new cod files (included sibling files).
byte[] Codbuff = null;
string[] cod = new STRING[3];
Assuming that application contents 3 cod files.
Cod[0] = getviahttp ("ModuleName");
COD[1] = getviahttp ("moduleName-1");
COD[2] = getviahttp ("moduleName-2");
System.out.println ("Download Complete");
int newhandle = 0;
API REFERENCE://You need to write the ' data in two separate chunks.
The chunk must is less thank 64KB in size. int maxappend = 61440;
1024*60;
for (int i = 0; i < 3; i++) {Codbuff = Cod[i].getbytes (); if (Codbuff.length > Maxappend) {newhandle = Codemodulemanager.createnewmodule (Codbuff.length, CodBuff, MAXA
Ppend); Boolean APPENDSUCC = Codemodulemanager.wriTenewmodule (Newhandle, Maxappend, Codbuff, Maxappend, codbuff.length-maxappend);
Codbuff = null;
else {newhandle = Codemodulemanager.createnewmodule (Codbuff.length, Codbuff, codbuff.length);
}//install the "module if" (Newhandle!= 0) {int savecode = Codemodulemanager.savenewmodule (Newhandle, true); if (Savecode = = Codemodulemanager.cmm_ok_module_overwritten) System.out. println ("The operation completed essfully;
A module is overwritten and marked for deletion in the process. ");}
SYSTEM.OUT.PRINTLN (i + "module installed"); //restart the BlackBerry if reuired if (codemodulemanager.isresetrequired ()) Codemodulemanager.promptforresetifreq
Uired ();
}