Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Contributor
Posts: 4
Registered: ‎06-02-2011
My Device: tour 9630
My Carrier: airtel nigeria

Blackberry torch 9800 compactibility issues

On tour 9630 and most other blackberry os devices my apps loads reasonably fast but not torch 9800 in particaular. my webworks app will take nearly forever to pass the loading screen. besides that i'm also having issue adapting my dom when the user rotates his/her device. the later should a second issue that i will somebody to assist me the best method to adapt to screen rotations.

 

my initiation code is as detailed below:-

 

function doInit() {

  loadBusyCard();

  initialise();

}

function  initialise() {

conn = getConn();

conn.onreadystatechange =

function() {

 

if(conn.readyState == 4 && conn.status == 200) {

 

try{

 

var success = false;

 

var data = eval('(' + conn.responseText + ')');

 

//checkupgrade

if (data.d.iCheckUpgrade.indexOf('http') > -1) {

..................................

 

i also noticed that screen.width property on torch returns an unreasonable value, in fact too high. this is my first shot at webworks and i really wish i could deliver a light yet blackberry model independent app for a certain corporate client.

 

Your suggestions and advice will be highly appreciated.

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Blackberry torch 9800 compactibility issues

Are you setting the meta tags for viewport width/height for your HTML.. that may correct your screen width issue.

 

If the JavaScript you posted is running in an embedded script tag in the <head> then it will be running before the page dom loads.  Without seeing what the contents of the functions you are calling do, it is hard to tell what may be slowing things down for loading on a 9800.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Contributor
Posts: 4
Registered: ‎06-02-2011
My Device: tour 9630
My Carrier: airtel nigeria

Re: Blackberry torch 9800 compactibility issues

thanks for finding time to respond. for the screen.width issue my meta tag reads

<meta name="viewport" id="viewport" content="height=device-height,width=device-width,user-scalable=no"/>

 

while my code is this:-

 

<script type="text/javascript">

addEventListener('load', doInit, false);

 

blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK, Back);

 

//properties

......

...... 

 

functiondoInit() { 

loadBusyCard();

initialise();

}

 

conn = getConn();

conn.onreadystatechange =

function() {

 

if(conn.readyState == 4 && conn.status == 200) {

 

try{

 

var success = false;

 

var data = eval('(' + conn.responseText + ')');

 

//checkupgrade

if (data.d.iCheckUpgrade.indexOf('http') > -1) {

loadUpgradeCard(data.d.iCheckUpgrade);

return;

}

//chaturl

if (data.d.iChatUrl.indexOf('http') > -1) {

chaturl = data.d.iChatUrl;

}

//advert

if (data.d.iAdvert.ImageUrl.indexOf('http') > -1) {

advert = data.d.iAdvert;

advimg = newImage();

advimg.src=data.d.iAdvert.ImageUrl;

advimg.onload = function(){

advimgloaded = true;

 

if(document.getElementById('advert') != undefined){

document.getElementById('advert').src=advimg.src;

}

};

success = true;

}

success =false;

 

if(data.d.iForex.length > 0){

forex = data.d.iForex;

success =

true;

}

//stocks

success =false;

 

if(data.d.iStocks.length > 0){

stocks = data.d.iStocks;

success =true;

}

//products

if(success && data.d.iProducts.length > 1){

products = data.d.iProducts;

readProdCategories();

loadMenuCard();

try{

loadNativeMenus();

}

catch(x){}

}

else{

document.getElementById('status').innerHTML = "Incomplete read process, initialization failed";

}

}

catch (ex) { document.getElementById('status').innerHTML = "Read error, initialization failed"; }

}

elseif(conn.readyState == 4 && conn.status != 200) {

document.getElementById('status').innerHTML = "Initialization failed, check connection & try again";

}

};

conn.open('GET', server + "Initialization?w="+width+"&h="+height+"&model=" + model + "&version=" + version, true);

conn.send(null);

}

 

thanks a lot again

New Contributor
Posts: 4
Registered: ‎06-02-2011
My Device: tour 9630
My Carrier: airtel nigeria

Re: Blackberry torch 9800 compactibility issues

thanks for finding time to respond. for the screen.width issue my meta tag reads

<meta name="viewport" id="viewport" content="height=device-height,width=device-width,user-scal​able=no"/>

 

while my code is this:-

 

<script type="text/javascript">

addEventListener('load', doInit, false);

 

blackberry.system.event.onHardwareKey(blackberry.s​ystem.event.KEY_BACK, Back);

 

//properties

......

...... 

 

function doInit() { 

loadBusyCard();

initialise();

}

 

function initialise(){ 

conn = getConn();

conn.onreadystatechange =

function() {

 

if(conn.readyState == 4 && conn.status == 200) {

 

try{

 

var success = false;

 

var data = eval('(' + conn.responseText + ')');

 

//checkupgrade

if (data.d.iCheckUpgrade.indexOf('http') > -1) {

loadUpgradeCard(data.d.iCheckUpgrade);

return;

}

//chaturl

if (data.d.iChatUrl.indexOf('http') > -1) {

chaturl = data.d.iChatUrl;

}

//advert

if (data.d.iAdvert.ImageUrl.indexOf('http') > -1) {

advert = data.d.iAdvert;

advimg = newImage();

advimg.src=data.d.iAdvert.ImageUrl;

advimg.onload = function(){

advimgloaded = true;

 

if(document.getElementById('advert') != undefined){

document.getElementById('advert').src=advimg.src;

}

};

success = true;

}

success =false;

 

if(data.d.iForex.length > 0){

forex = data.d.iForex;

success =

true;

}

//stocks

success =false;

 

if(data.d.iStocks.length > 0){

stocks = data.d.iStocks;

success =true;

}

//products

if(success && data.d.iProducts.length > 1){

products = data.d.iProducts;

readProdCategories();

loadMenuCard();

try{

loadNativeMenus();

}

catch(x){}

}

else{

document.getElementById('status').innerHTML = "Incomplete read process, initialization failed";

}

}

catch (ex) { document.getElementById('status').innerHTML = "Read error, initialization failed"; }

}

elseif(conn.readyState == 4 && conn.status != 200) {

document.getElementById('status').innerHTML = "Initialization failed, check connection & try again";

}

};

conn.open('GET', server + "Initialization?w="+width+"&h="+height+"&model=" + model + "&version=" + version, true);

conn.send(null);

}

 

thanks a lot again

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Blackberry torch 9800 compactibility issues

Have you tried placing in date time stamp logging... i.e. create a global array that you add Start/Stop times for each of your functions and then print it out as a log at the end to see which methods are causing the slow down?

 

That should give you an idea of which function is taking up all the time for you.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Contributor
Posts: 4
Registered: ‎06-02-2011
My Device: tour 9630
My Carrier: airtel nigeria

Re: Blackberry torch 9800 compactibility issues

i noticed that on v6 BBs, the device starts running my scripts even when the loading screen is still showing. then the following code will not add native menu options on them:

function loadNativeMenus() {
if (blackberry.ui.menu.getMenuItems().length > 0)
blackberry.ui.menu.clearMenuItems();
var call = new blackberry.ui.menu.MenuItem(false, 1, "Call Acme", callAcme);
blackberry.ui.menu.addMenuItem(call);

var chat = new blackberry.ui.menu.MenuItem(false, 2, "Start LiveChat", loadChatCard);
blackberry.ui.menu.addMenuItem(chat);
var offl = new blackberry.ui.menu.MenuItem(false, 3, "Send Offline Msg", loadOfflineMsgCard);
blackberry.ui.menu.addMenuItem(offl);
var tella = new blackberry.ui.menu.MenuItem(false, 4, "Tell A Friend", tellAFriend);
blackberry.ui.menu.addMenuItem(tella);
var main = new blackberry.ui.menu.MenuItem(false, 5, "Main Menu", loadMenuCard);
blackberry.ui.menu.addMenuItem(main);
}

while this will will also fail to launch native browser

function followLink(address) {
var encodedAddress = "";
// URL Encode all instances of ':' in the address
encodedAddress = address.replace(/:/g, "%3A");
// Leave the first instance of ':' in its normal form
encodedAddress = encodedAddress.replace(/%3A/, ":");
// Escape all instances of '&' in the address
encodedAddress = encodedAddress.replace(/&/g, "\&");

//if (typeof blackberry !== 'undefined') {
try{
// If I am a BlackBerry device, invoke native browser
var args = new blackberry.invoke.BrowserArguments(encodedAddress);
blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);
} catch(e) {
alert("Sorry, there was a problem invoking the browser");
}
//} else {
// If I am not a BlackBerry device, open link in current browser
//window.location = encodedAddress;
//}
}

sorry am beginning to bug you too much, just the last one. the display scales well on tour where as on curve it is too large.

i have a demo tomorrow and will likely run my app on different models.

thanks