Threading in extension of blackberry widget

Hello, I am new to blackberry widget development. I created an extension that allows me to get a precise gps location, however my application hangs while he does this, how can I implement threading in my extension.

I searched for days and has been unable to find anything. Any help I appreciated

What platform are you on?  BB OS 5.0 or 6.0?  There is a difference in threading between the two.

The Widget JavaScript Extensions are on the thread to dispatch event application on 6.0, but not on 5.0.  In both cases, however, you must configure your GPS receiver on a separate extension thread.  It is done the same thing, as in any other Java environment, using Thread or Runnable classes.

public class MyExtensionFunction extends ScriptableFunction {    public Object invoke(Object obj, Object[] oargs) throws Exception {        // Run this on a background thread so that JavaScript can continue on        Thread thread = new Thread(new Runnable() {            public void run() {                // set up GPS listener here            }        });        thread.start();    }}

Tags: BlackBerry Developers

Similar Questions

  • Thread blackBerry Widget model

    Anyone know where there is a documentation on the threading model used in the BlackBerry Widgets?

    Run this wire Java code that is called from JavaScript? For example if I have

    scriptEngine.addExtension("window.someFeature", new SomeFeature());
    

    and then run a method like

    window.someFeature.foo()
    

    starting from JavaScript, this thread the corresponding Java code run?

    For example from this code I'm sure calling something like

    scriptEngine.executeScript("alert('foo')");
    

    Thank you!

    The extension will take place in the thread of JavaScript.  It is to be careful in your code if you access something that runs in the UI thread.

    If you're not careful, you can get in a deadlock situation.  An example of a deadlock situation, we met with our navigation mode can be found here:

    http://supportforums.BlackBerry.com/T5/Web-development/focus-based-navigation-hangs-device/TD-p/4556...

    We have created a fix on the way to a handful of situations where you need sometimes to go to the UI thread and do it safely.  If you look at source code for navigation mode found in the patch of BlackBerry 6 we published, you will see how we are misleading treatment to another thread that is not the UI thread to get around any possible blocking scenario.

    The source code of this patch can be found here:

    http://supportforums.BlackBerry.com/T5/Web-development/supporting-BlackBerry-widget-applications-on-...

    Check out the code in the device_templates directory.

    An another good rule of thumb is that if your code might work for a period of time, to implement a callback interface asynchronous instead of blocking the thread of JavaScript.

  • Blackberry widget static header/footer positioning

    I worked retail fixed header/footer in my blackberry widget. Here's my progress:

    
    
        
            
            Blackberry Header and Footer
            
            
        
        
            
            
    // content goes here

    It is obviously not the best coding in the world, but it seems to work OK, except that I can't scroll the content when it is large.

    I've searched around, but couldn't find much information about him.

    It would be nice to have a standard header/footer, with the hacks built in work.

    If I could somehow overflow of average content to scroll with touch screens, then it should be good to go, right? Also, to implement other features... etc...

    I have not yet tried jQuery mobile, but some things you may be bumping into one I've seen documented.

    Currently, jQuery mobile only supports the torch and the BlackBerry webkit browser. They intend to make browsers more ancient in the mix that they continue with jQuery mobile (I think that all the way back to the browser of 4.7 on the storm).

    Second, I noticed that some of jQuery contained the names of file a ' - '. You will need to rename these files and make sure that all the links in the library are not violated between all the files for the compiler to BlackBerry widget to consume these resources.

    just the two big things I can think of that you can encounter. I'll post to the top if I have the chance to try the library.

  • trying to jquery mobile (alpha2) working in a Blackberry widget

    Sorry, I'm rather new with widget development.

    I try to get mobile jquery working in a widget on a blackberry 9780.
    If anyone has tried it, please let me know if it is worth.

    My first question was that jquery uses dashes in filenames, which seems
    be banned in Blackberry widgets, so I had to change all the dashes to emphasize.

    Today's question is Packer message: "Invalid widget archive - reserved found directoy.
    No error number. Y at - it a packager error messages published index. Are there rules

    on the directory names? They have to be reported in the xml file?

    bbwp version - 1.5.0.18

    mobile jQuery - 1.0a2

    resolved - Packer Widget was to launch "/ bin" directory. I guess "/ bin" is a reserved directory name.

  • The Service WCF and Blackberry Widget does not. See where I am going wrong?

    I'm creating a widget of BB with Visual Studio 2008 and I created a WCF Service hosted in Windows Azure.

    This is one of the methods in the WCF Service:

     public string ClockIn(string emailAddress)
            {
                try
                {
                    using (var dc = new TEI_DataContext(_MyDc))
                    {
                        SecurityLogin sl = dc.SecurityLogins.SingleOrDefault(s => s.EmailAddress == emailAddress);
                        var tc = new TimeClock { ClockIn = DateTime.Now, UserName = sl.UserName };
                        dc.TimeClocks.InsertOnSubmit(tc);
                        dc.SubmitChanges();
                        return "You're Clocked In!";
                    }
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
    
            }
    

    I tested it with a Console Application like this, and it works GREAT!

    var client = new TEIServiceReference.Service1Client();
    string result = client.ClockIn("[email protected]");
    Console.WriteLine(result);
    Console.Read();
    

    Here is the address of public WCF Service: http://a1e17152bcf647aaa300ccb5a8a2a2c5.cloudapp.net/Service1.svc

    Here is my HTML code for the widget:

    
    
    
    
    TEI Time Clock
    
    
    
    
    
    

    And here's my JavaScript code:

    var xmlHttp = new XMLHttpRequest();
    
    function ClockIn()
    {
    var url = "http://a1e17152bcf647aaa300ccb5a8a2a2c5.cloudapp.net/Service1.svc/ClockIn/[email protected]";
    xmlHttp.open('GET', url, true);
    xmlHttp.onreadystatechange = callbackFunctionClockIn;
    xmlHttp.send(null);
    }
    
    function callbackFunctionClockIn()
    {
    
    if (xmlHttp.readyState == 4)
    {
    var result = xmlHttp.responseText;
    //result = result.getElementsByTagName("string")0].childNodes[0].nodeValue;
    alert(result);
    }
    }
    

    When I run the widget, an EMPTY popup appears and it NOT me clock. Can you see what I'm missing?

    Thanks a lot for your help and your time!

    Brenda

    The? did not help either. Bad luck!

    I just hired a Blackberry app developer, and he thought of it in Java.

    Thanks for trying to help out well!

  • AJAX request works just with a Wi - fi Blackberry Widget

    I'm doing an Ajax request to're RESTful WebService. When I run the Simulator everything works fine, but when I install the widget for blackberry on my device (9800) applications works when I'm using the Wifi connection...

    It's my config.xml file:

    
    http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="0.2.0.0">
      bbbb
      bbbb
      
      
      
      
      
      
      
      
      
      
        
        
        
        
        
        
        
        
        
      
      
      
      
        TCP_WIFI
        MDS
        BIS-B
        TCP_CELLULAR
        WAP2
        WAP
      
      
      
    
    

    Why this is happening?

    Finally! I found it! I have no why, but it works only on .com, .net o .org domains

    I made the request to a .mobi domain.

  • BlackBerry widget background-attachment: fixed;?

    Does anyone know how to create a fixed background image? Finally, I would like to have fixed a fixed background image with a header div, but I work on one thing at a time...

    See you soon,.

    G

    By fixed... Do you mean using a div in a fixed position via CSS?

    If so, do not make the fixed fixed positioned divs on BlackBerry.  They will scroll/jump with the content.  It's just a limitation of the implementation.

    I posted an example of a header/footer show/hide to parchment here:

    http://supportforums.BlackBerry.com/T5/Web-development/fixed-position-toolbars-example/TD-p/643949

  • Of Blackberry widgets can run on the Pearl 8100?

    Hello

    I'm creating an application or widget for a customer who has already purchased the Pearl 8100 for its employees. The widget or app must fill out a form, store data locally, and if there is network coverage, send the data online. Given that I can't edit or update the device, is the approach of widget completely out the window? From what I gathered, the widgets are for OS5 and this operating system is not available for the 8100 pearl.

    Thank you

    -Zach

    Hello Zach,

    Unfortunately, you will not be able to run widgets on a 8100. They are not able to be upgraded to OS 5.0

  • Extensions of blackBerry Smartphones automatically add

    Hello

    I bought a used Blackberry Bold 900 V4.6.0.162 (Platform 4.0.0.155)

    When I type a number it works fine, but when I add the same number to contact list, then it adds to + 44 in the number automatically and remove 0.

    by example, if I save this 03005977333 on the name of James, when I select james and then dial the number called is, + 443005977333

    I want to call to the 03005977333

    Please help me on this.

    Thank you

    Got it, thanks it was Smart purchase option that he fixed.

    Thank you

  • Widget Javascript Extension: reminder

    Hi guys,.

    I am currently developing widgets using Javascript Extension also.

    I am facing a problem.

    In my class that extends from ScriptableFunction, how do I manage an object passed to call methods as arguments and representing a "pointer" to the javascript function to use as the asynchronous callback?

    How can I call it?

    Thank you very much.

    Concerning

    Scarex

    Hi Scarex,

    It's a really great question.  You can execute JavaScript in Java by using the executedScript() method which accepts a string as a parameter.  Rather than pass a pointer to a JavaScript method, you can provide the name of the function as well as all the parameters.

    Here's an example of how you could spend two whole arguments to a ScriptableFunction and make a call to a JavaScript function named 'add', passing the following values:

    ScriptableFunction _myFunc = new ScriptableFunction()
    {
       public Object invoke(Object obj, Object[] args) throws Exception
       {
          if (args.length == 2) {
             int param1 = ((Integer)args[0]).intValue();
             int param2 = ((Integer)args[1]).intValue();
             _browserField.getScriptEngine().executeScript("add(" + param1 + ", " + param2 + ")", null);
          }
          return UNDEFINED;
       }
    };
    

    Here's what could resemble the method add() method JavaScript, defined in the BlackBerry Widget application web content:

    
    

    I hope this helps.

    Best wishes

    Adam

  • Webworks Blackberry application does not not remote page on Simulator

    My application Blackberry Webworks a problem opening a remote page when testing it in a Blackberry Simulator (I tried Verizon 9630, 9700-ATT, 9860-Asia). Whenever I try to open a remote page in my application webworks, the application crashes, and after a while, I get a white screen with the error error 104 Eception App: InterruptedIOException and when I click on continue a dialog message box comes up with the message Local connection timed out after ~ 120000. If I open this URL in the browser of the Simulator, it opens right away. What I don't know, this is why it does not open in the webworks app.

    Now the funny part is, if I load the same webworks app in my blackberry device, it works perfectly. It opens the remote page immediately. I don't know why its not working in a simulator.

    I have the config.xml file properly configured with the remote url defined in the element of access:

    http://sample-remote-server.com/" subdomains="true" />
    

    I will be very happy if someone can spare their time to help me.

    Thanks in advance.

    bigjavajoe wrote:

    Do not know if I did... I just open the Simulator and load my webworks app.

    How to make the MDS?

    If you are using eclipse, see this thread:

    http://supportforums.BlackBerry.com/T5/Web-and-WebWorks-development/cannot-connect-to-Internet/TD-p/...

    But if you don't use eclipse or just command-line bbwp, try to find the mds file in your path of Blackberry Webworks (usually in \Program Files\Research in Motion\BlackBerry Widget Packager\mds),

    After searching for the folder, find the run.bat file, then run it.

  • How to handle shared extension webworks reference library

    My webworks extension uses a shared reference library.  The library module is deployed with an agent java application on the device already. In case of native java application, other applications that use this library shared do not overload the library during deployment.

    In the case of webworks app, seems that I have to put the library jar file in the root of the webworks app to be able to compile the web extension to bbwp command. However, after I deployed the cod file, I get prompt the class in the library has been defined in several.

    Is there a way to not wrap the library with the webworks app file?

    June

    I got response source RIM on another thread of e-mail and it workd form me. I post the answer here to share.

    The recommended method for distributing webworks extension is to copy the source in the ext of the webworks SDK folder. This will allow you to use a single code base across multiple use of a same extension. How to distinguish a pot for the inclusion of a compile-time only jar is with an additional label in the library.xml for dependencies.

    sample: bbm webwork extension:

    blackberry.bbm.platform.BBMPlatformExtension

    June

  • Cannot connect widget - unable to find signature keys

    About 1 year ago, I installed Eclipse and plugin BB to develop java applications of BB. I had bought and installed signature keys and was able to sign the apps very well at the time.

    Then, I want to write a 'widget' using the new (for me) web plugin for eclipse. The only way I could get that work was by installing the all-in-one "BlackBerry Web plug-in in Eclipse" (the package that has the correct version of eclipse plugin extension). The only problem is that I can't sign widgets.

    So, in summary, I have two versions of Eclipse on my computer:

    1. a version with the blackberry java plug-in for making java applications (that I could sign)

    2. the version with the blackberry widget plugin to make apps widget (I can not sign)

    The error I get from the BlackBerry Web/Widget to eclipse version when I try to sign my widget is:

    Cannot connect widget - unable to find signature keys

    Do I need to import the key somehow (wherever they are) of the old version of Eclipse for the 'new' or perhaps reinstall?

    Or even buy them?

    Note: I still have the original files of .csi 3 If this is useful

    Any help on this would be greatly appreciated...

    Thank you for your response. I had sent dev support and received the following response (which is essentially the same thing you said):

    Please contact BlackBerry Application Development Support.

    When you install your signing keys, first they are only registered with a JDE 1. Specifically, most recently installed JDE on your machine. Following these steps, you should be able to activate the privileges of your signature for all d located on your computer:

    (1) locate your signing keys by searching your computer for sigtool.db. You can find several files of sigtool.db, but you are looking for the sigtool.db that, if opened with a text editor, you see references to all three signatories (RBB, RRT and CPR) as follows:

    #The file of database containing information to request signatures.
    #[DATE]
    RBB = [CLIENT_ID] http\: / /www.rim.net/Websigner/servlet/BBApps
    RRT = [CLIENT_ID] http\: / /www.rim.net/Websigner/servlet/Runtime
    CPR = [CLIENT_ID] http\: / /www.rim.net/Websigner/servlet/CryptoRIM

    You can find this file, go to the next step if we can deliver a set of replacement of signature keys, free of charge.

    (2) COPY the 4 following four files in the same folder as you find the sigtool.db file in:
    -sigtool.db
    -sigtool.set (if this file does not exist, it is good to ignore it).
    -sigtool.csk
    -SignatureTool.jar

    (3) If you are using Eclipse 3.5.1 or more, there is a shared folder where you can PASTE your signature files, by default:
    C:\Program Files\Eclipse\plugins\net.rim.ejde\vmTools

    If the vmTools folder does not exist, you will need to PASTE the 4 four files for each component pack individually, by default:
    C:\Program Files\Eclipse\plugins\net.rim.ejde.componentpackx.x.x_x.x.x.x\components\bin (where x.x.x_x.x.x.x is the version of the component Pack.)

    If you use BlackBerry JDE, please note that there is no shared folder. You will need to associate each individual JDE with the privileges of your signature and PASTE the files in each associated BIN folder:
    C:\Program Research In Motion\BlackBerry JDE x.x.x\bin (being the JDE version x.x.x.)

    Finally, if you are using BlackBerry Widgets, you can PASTE the files in the next BIN folder, by default:
    C:\Program search in Motion\BlackBerry Widget Packager\bin

    By copying the files of four 4 and sticking them in the BIN of your d files, you copy your signature to these can thus privileges. Please note that this approach will allow the privileges of signature for all on a 1 d machine, but will not work for d on other machines; signature keys cannot be installed on 1 machine.

    If you have any questions about the process described above, feel free to contact me.

    Kind regards

    Erik
    Software engineering analyst
    Application development support
    Research In Motion Limited
    [email protected]
    http://www.BlackBerry.com/developers

    Well, it turns out that I had no sigtool. [something]... I wrote and they sent me another set of keys as promised.

  • call a javascript extension

    Hey

    I am very new to Blackberry/Java development if any help would be great.

    Using the tutorial on how to create blackberry javascript extensions that I wrote a very simple extension that will download a file from you.  Everything seems fine, I can export the JAR but I get the following in eclipse warning:

    Description Resource Path Location Type
    Signing Required: RIM Blackberry Apps API (0x52424200): Import uses protected Class net.rim.device.api.web.WidgetConfig ByteReaderExtension.java /TribalWorksByteReader-OS6/src/tribal line 5 BlackBerry Protected API
    

    When I try to use the extension to javascript in my application webworks, nothing happens.  Simply, it stops and does not receive from past the line, where I make my call.

    alert("before extension call");
    tribal.download.downloadFile(remoteFile, localFile);
    alert("after extension call");
    

    In the emulator, I get the first alert, but not the second.  I'm also a few calls from Dialog.alert in my extensions javascript that ever fire.  Kind of I'm stuck at this stage since there is no errors so I don't really know where to start.

    Someone knows something similar or know how I can fix this?

    Packer widget 1.5

    OS: 6.0.0.337

    Device: 9800

    I am also to build my javascript extension nuer Blackberry JRE 6.0.0

    Edit: I'm also compiling the application with bbwp.exe

    Thank you!

    Chris

    I thought about it.

    I used a file struggle to update the index.zip and compile it with bbwp.exe.

    I forgot to add the ext for the zip folder.

  • Widgets on pre 5.0 devices

    At a high level, what are the OS 5.0 required features that are not available for devices running OS< 5.0? ="" in="" other="" words,="" is="" there="" going="" to="" be="" any="" way="" to="" run="" widgets="" on="" older="">

    I like the new method of development of widget, but it will be a moment very, very long time before of OS 5.0 will be widely used.  Once the new OS 5.0 is released for older devices, it takes a long time for carriers to make them accessible, and there are still like for users and companies to actually upgrade the devices more ancient (if any).

    Fred

    Hi Fred,.

    There are two main components that are on 5.0 that allow widgets.

    (1) BrowserField2 that allows custom JavaScript extensions

    (2) BlackBerry Widget JavaScript API that are part of the operating system

    So without these two items on the older operating systems, widgets do not work.

    Updating and dissemination of the new operating system takes time.  It is a technology which is something that we are eager to build and also provide a new way for the development on new smartphones as they come out.

Maybe you are looking for

  • Return to Castle Wolfenstein - platinum edition

    I uninstalled Return to Castle Wolfenstein, reinstalled on my new Dell with Vista OS.Vista can not read my program files where I loaded all my card games and downloads.When I join a server, I am often struck for lack of information Punk Buster, altho

  • Limit RAM to 2 gigabytes with Pavilion dv6000 (actually 6408nr)

    I tried to upgrade to 4gigs, but was only required to 2gigs. I have a 64 bit system with Windows Ultimate edition. I checked and I have the latest version of the bios F.43 (3/2010). I also have an AMD processor. If there is any help that you can prov

  • laptop does not recognize new memory RAM

    Hello I have the Aspire E1-572-74504G50Mnkk i7-4500U with 8.1 64-bit windows. I just bought a 4 gb Kingston Valuaram, when I insterted it in my notebook, in Panel I can't see the new memory. However, I see 8192 mb with the PCwizard program. He was al

  • VSOM MSP RHEL Server runtime error

    Hello I encountered the problem in VSOM in MSP RHEL Server loading. Login page displays no value. Error loading /media1 during the startup process of RHEL. It says "editing local files system error" and "mount: structure needs to be cleaned. After re

  • Result of the dialog box

    Hello I have a background application that listens to a webservice and informs the user if he has a new message. I use the following code: UI UiEngine is Ui.getUiEngine ();. Dialog dlg = new dialog box (Dialog.D_YES_NO, "you have a new Message... ui.