Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A similar method but one that I find a bit better than Richard's thought above because the client does not need a hard-coded JAD path this way (important since JAD files may differ for different BB OS versions): </p> <ol> <li><p>create a simple web page (php, jsp, servlet, cgi, whatever) that accepts app name and current app version as input; if you need it, also include OS version in the input.</p></li> <li><p>This URL will be constructed by the client by obtaining the appropriate data (details below) and appending it to the known base URL. </p></li> <li><p>the web page will parse the information, and calculate the proper version to run. </p> <ul> <li>Note that you might not need all of the information above: if you only have one downloadable version of your app, you would really only need the device to send the client software version and nothing else. The calculation of proper version can be a simple hard-coded check (if ($version != LATEST_VERSION)) or something more complex, involving lookup into a database or elsewhere. </li> </ul></li> <li>This page will output plain text, non-HTML. It will write three values, one per line: <ol> <li>"y" if an update is required , "n" if not. </li> <li>The current-most version for this client to use. This is only necessary if you want the client to display it. </li> <li>the download URL for the correct JAD. </li> </ol></li> <li>The client application will parse that data, and if the first flag is "Y" will display message "The current version is (contents of second line). Would you like to update?" When update is selected, it will launch the URL provided in the third line. </li> </ol> <p><strong>Reference</strong></p> <p><em>Obtaining Application Version</em> </p> <pre><code>import net.rim.device.api.system.ApplicationDescriptor; ... // Returns current app version in the format Major.Minor.Minor.Build, eg 1.5.1.123 String version = ApplicationDescriptor.currentApplicationDescriptor().getVersion(); </code></pre> <p><em>Obtaining Hardware and Platform Info</em> </p> <pre><code>import net.rim.device.api.system.ApplicationDescriptor; ... // Obtain the platform version string in the format A.B.C.DDD, eg 5.0.0.464 String softwareVersion = DeviceInfo.getSoftwareVersion(); // Obtain the hardware name: String hardwareName = DeviceInfo.getDeviceName(); </code></pre> <p><em>Launch HTTP URL</em> </p> <pre><code>import net.rim.blackberry.api.browser.Browser; Browser.getDefaultSession().displayPage("http://example.com"); </code></pre> <p><em>Read HTTP file</em> </p> <pre><code>String url = "full/url/assembled/with/data/above" // YOU assemble "url" value - and include more error handling than is here in this sample: HttpConnection conn; try { conn = ConnectionHelper.getHttpConnection(url); LineInputStream stream = new LineInputStream(conn.openInputStream()); String lineOneYesNo = stream.readLine(true); String lineTwoCurrentVersion = stream.readLine(true)) String lineThreeDownloadURL = stream.readLine(true)) // *** // * Parse the data above and handle as described. // *** return data; } catch (IOException e) { // Add appropriate erorro handling here return; } </code></pre> <p><em>getHttpConnection Implementation</em> </p> <pre><code>public static HttpConnection getHttpConnection(String URL) throws IOException { HttpConnection c = null; StringBuffer conn = new StringBuffer(URL); // *** IMPORTANT *** // YOU must define this method below, as it will append // values to the connection string based on connection // type (MDS, TCP, WIFI, WAP2, etc) // configureConnectionString(conn); c = (HttpConnection) Connector.open(conn.toString()); int rc = c.getResponseCode(); if (rc != HttpConnection.HTTP_OK) { throw new IOException("HTTP Error: " + rc); } return c; } </code></pre> <p><em>Reference: Simple LineInputStream implementation</em> </p> <p><a href="http://svn.bbssh.org/trunk/BBSSH_Common/src/org/bbssh/io/LineInputStream.java" rel="nofollow noreferrer">http://svn.bbssh.org/trunk/BBSSH_Common/src/org/bbssh/io/LineInputStream.java</a></p> <p><em>Sample Input URL 1</em> This URL is constructed by the client and sent to the server: </p> <pre><code>http://example.com/versioncheck.do/app-name/hardware-name/os-version/app-version e.g. http://example.com/versioncheck.do/MyApplication/Bold9000/5.0.466/1.5.1.0 </code></pre> <p><em>Sample Input URL 2</em> Alternative format for the same thing: </p> <pre><code>http://example.com/versioncheck.php?appName=A&amp;hardwareName=B&amp;osVersion=C&amp;appVersion=D e.g. http://example.com/versioncheck.php?appName=?MyApplication&amp;hardwareName=Bold9000?osVersion=5.0.466&amp;appVersion=1.5.1.0 </code></pre> <p><em>Sample Output</em> </p> <pre><code>y 1.3.1.125 http://example.com/ota/5.0.0/MyApp.jad </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload