HTML5 App - See the pop-up message window when in the background

Hello

I need my application to display a popup to the user even if the application is in the background.

How can I do this if my application is built with html5 and JavaScript?

Thanks for any help

Hello Wadi,

This has proved to be a bit of a monster post. If you have any questions at a stage any post, do not hesitate to ask. Let's dive.

There are a few issues I see with the code you provided.

PopupExtension.java


  • Creates an AlertNamespace object, your class is called PopupNamespace.

PopupNamespace.java


  • getField is not implemented. \

PopupFunction.java


  • A lot of import declarations are missing.

I'll show you a comparison of my files, I managed to get the dialog box displayed from in my WebWorks app; No matter whether the application is in the foreground or background.

For reference, the creation of my java files is based on the examples of code available here:

https://bdsc.webapps.BlackBerry.com/HTML5/documentation/ww_developing/using_javascript_extensions_18...

For starters, I have SandboxExtension.java. It is the equivalent of your PopupExtension.java.

package sandbox.extension; 

import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.script.ScriptEngine;
import net.rim.device.api.web.WidgetConfig;
import net.rim.device.api.web.WidgetExtension;
import org.w3c.dom.Document;

public final class SandboxExtension implements WidgetExtension {
    String _widgetNameForFutureUse;
    BrowserField _browserFieldForFutureUse;

    public String[] getFeatureList() {
        String[] result = new String[1];
        result[0] = "sandbox.popup";
        return result;
    }

    public void loadFeature(String feature, String version, Document doc, ScriptEngine scriptEngine) throws Exception {
        if (feature.equals("sandbox.popup")) {
            scriptEngine.addExtension("sandbox.popup", new SandboxScriptable());
        }
    }

    public void register(WidgetConfig widgetConfig, BrowserField browserField) {
        _widgetNameForFutureUse = widgetConfig.getName();
        _browserFieldForFutureUse = browserField;
    }

    public void unloadFeatures(Document doc) {
    }
}

Main differences


  • I've updated my package to sandbox.extension it is unique (less chance that it has already been used.)
  • In getFeatureList, I and by using the function sandbox.popup; It was purely a personal choice I made during the implementation of the example. There is no real functional difference.
  • Subsequently to the first point, I also refer to sandbox.popup in my remaining code; more precisely within loadFeature.
  • My method of register sets two corresponding member variables.
  • I create a new SandboxScriptable object as opposed to your object of AlertNameSpace.

The following file is SandboxScriptable.java. It is the equivalent of your PopupNamespace.java file. Note that this class must refer to the object that is created in the file above. In my case, I created an object of SandboxScriptable , so I'm now implement SandboxScriptable.java to define this object.

package sandbox.extension;

import net.rim.device.api.script.Scriptable;

public final class SandboxScriptable extends Scriptable {

    private SandboxPopup _sandbox;

    public SandboxScriptable() {
        _sandbox = new SandboxPopup();
    }

    public Object getField(String name) throws Exception {
        if(name.equals("doPopup")) {
            return this._sandbox;
        }
        return super.getField(name);
    }
}

Main differences


  • Slight changes to naming to accommodate my variable names.
  • The getField function is (and must) be implemented. In fact, when a method is called, I check to see if it is the doPopup method. If so, I returns a SandboxPopup object. This would be your PopupFunction class. If the user does not call the doPopup method, I just pass back the default behavior via the super object.

The final class is SandboxPopup.java. It is the equivalent of your PopupFunction.java. Above, we create and return an object of SandboxPopup , so in this file that we actually apply this that the object is actually.

package sandbox.extension;

import net.rim.device.api.script.ScriptableFunction;
import net.rim.device.api.system.Application;
import net.rim.device.api.ui.UiEngine;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Manager;

public final class SandboxPopup extends ScriptableFunction {
    public Object invoke(Object obj, Object[] args) throws Exception {
        synchronized(Application.getEventLock()) {
            UiEngine ui = Ui.getUiEngine();
            Screen screen = new Dialog(Dialog.D_OK, "Hello World!", Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.VERTICAL_SCROLL);
            ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_QUEUE);
        }
        return "UNDEFINED";
    }
}

Main differences

  • I added all declarations of import for the different Classes of the RIM used.
  • I return a default value 'Not DEFINED' string regardless of the success.

And that is the essence of the java files. Basically, it is a string of three classes; the first refers to the second, and the second refers to the third. In your example, the chain is slightly broken, however can be fixed fairly quickly based on the notes above.

The next part that needs to be done is to associate your Javascript Extension with WebWorks. This can be done in two different ways.

  • Package your extension with your application. Described in the Javascript Extension guide link above.
  • Integrate your extension with your SDK WebWorks.

I opted for the latter, I find this approach a little simpler. The first thing we need to do is to copy our java files in the extension folder. The extension root folder that I used is as follows:

C:\Program search in Motion\BlackBerry 2.3.0.9\ext\ SDK WebWorks

In this case, I created a folder sandbox.extension to House my extension:

C:\Program search in Motion\BlackBerry 2.3.0.9\ext\sandbox.extension SDK WebWorks

I then copied the folder src housing my files java to get the following file structure:

Note that the CBC/sandbox sand/extension path is no coincidence because sandbox/extension's folder as dictated by the package structure that I used in my java files. More precisely:

package sandbox.extension;

The last thing missing is a library.xml file. I used the library.xml files available on Github WebWorks community API page as a starting point and made a few modifications for the following.


    
        sandbox.extension.SandboxExtension
    
    
        
            
        
    
    
        
            
        
    
    
        
    

Key information

  • The is set to point to the class that implements WidgetExtension. In this chain of three java files, it would be the first file.
  • Under , I set path = 'src' since the real package begins in the src subfolder.
  • Under I've set the id to sandbox.popup.

This file has been created under the sandbox.extension root folder, specifically:

C:\Program search in Motion\BlackBerry 2.3.0.9\ext\sandbox.extension SDK WebWorks

And that's all for the configuration of the SDK. Now, when I have an application that relies on this extension, I don't no need to include something more in my real application because this feature is now integrated directly with my SDK. To use this feature, I need to:

  • Include the feature in my file config.xml .
  • Call the function in my Javascript.

My file config.xml looks like as follows.


http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="1.0.0">
    Sandbox
    Oros
    

    

Very basic. The element indicates index.html will be our main entry point. The important thing here is that I have included the item with id = "sandbox.popup". " You will notice that it is the same id that we have defined in library.xml.

Finally, here is a small sample application that gives the user a button. Once this button is clicked, a timer is called during 5 seconds. At the end of those 5 seconds, the extension (and in turn a popup dialogue) is called.



    
    
    
        

        
    

As you can see, we add a to our page which, when clicked, will trigger the function of fire . The function of fire calls setTimeout with a founter of 5000 milliseconds.

The reason for this is to give you the opportunity to stay within the application, or limit its application with the red end call button. No matter whether you are in the application or the application is reduced, after 5000 milliseconds, the invokeExtension function is called.

In invokeExtension, you can see call us sandbox.popup.doPopup. sandbox. Popup is the object, we defined in library.xml and put subsequenty implement within our java files. doPopup is the function we defined to be processed in the java files.

Still, if you have any questions about the foregoing, please let me know.

Erik Oros

BlackBerry Development Advisor

Tags: BlackBerry Developers

Similar Questions

  • Unable to see the background activity - 12 Dreamweaver

    When you transfer files, I can't see the background activity.

    Windows 7

    12 of Dreamweaver

    The icon appears in the taskbar

    If I hover over him, I 'see' it

    But if I select it does not come to the front.

    Using alt - tab it brings to the front and by minimizing all other windows and then clicking on it does not come

    There are some bug fixes released after CS6 is released.  You should have the latest patch which is 12.03.  Although it is not always clear in the menu help, if it is installed.  So just click on help > updates.  See below for more details on what it contains.

    Adobe - Dreamweaver Support Center: Updaters

    When DW starts acting buggy, the 1st thing to try is to clear your Cache.

    http://forums.Adobe.com/thread/494811

    If this does not help, try to restore preferences

    http://helpx.Adobe.com/Dreamweaver/KB/restore-preferences-Dreamweaver-CS4-CS5.html

    Nancy O.

  • Windows mail opens the small message window when I use ctrl to delete messages mupltiple. Have to cross and close each window before I can delete.

    you are using windows vista 32. A new problem. When I try to run multiple deletes all leaky windows open in a small window. I have to go back and narrow everysmall window until I can do multipe deletes. This does happen evry time, but most of the time. the windows close in mail, then when I close the mail they appear on the desktop or open window browsers.

    Hello

    I suggest you try to perform the clean boot and check if it helps:

    http://support.Microsoft.com/kb/929135

    NOTE: When you are finished troubleshooting, make sure that restore you the computer mode normal startup such as suggested in step 7 of the above article.

    For more information, see these links:

    http://Windows.Microsoft.com/en-us/Windows-Vista/delete-messages-in-Windows-Mail

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-with-Windows-Mail

    It will be useful.

  • GPS apps in the background

    I have an iPhone 6 s upgraded to iOS 10 the day it came out last week and I noticed that applications using GPS are failing in the background when several applications are in use. I ran to the Waze to check the traffic and Google Maps at the same time to check something on Friday and has noticed that if she was in the background would tend to turn off after a few moments. When I turn back, she will have to acquire the road again. I also have a Fitbit load HR, which uses the GPS on the phone via bluetooth to create a map of my route. I have it worked out with my usual Runkeeper app (which normally works perfectly) and noticed that Runkeeper would be closed after a mile or more. When I went to him to my podcast app after my race, Runkeeper would start up and missed the last two miles of my race. In addition, the road saved by Fitbit seemed jumped all over the place. I know that it is not unusual for GPS from blip, especially when moving through areas with weak signal or cell mutation or all through the streets of the city with tall buildings, but it seems that the problems have become more coherent. I have not tried to run with a single application to see if I have the same problem, but will try tomorrow. I used only a single app for navigation (Waze) yesterday evening and he seemed also to close after it is placed in the background for a while. Has anyone else seen anything like this?

    Hello alexhoward,

    Thank you for using communities of Apple Support. It is my understanding GPS apps do not work in the background, after the update to iOS 10. I use GPS every time I travel. I know that it can be crucial for applications GPS running in the background. I'm happy to help you

    I recommend first restart your iPhone. This can solve many unexpected behaviours. Follow the steps below.

    1. Press and hold the sleep/wake button until the Red slider appears.
    2. Drag the slider to turn off your device completely off.
    3. Once the device turns off, press and hold the sleep/wake button again until you see the Apple logo.

    Restart your iPhone, iPad or iPod touch

    If the problem persists, reset your location service. This resets all settings at default location. Apps will be stop using your location until you grant them permission again. Go to settings > general > reset > reset the card and privacy. Here is some additional information on location Services.
    On privacy and location in iOS Services 8 and later versions

    See you soon!

  • When I saw a page in my browser, I see the background

    Recently when I try to view a page or the entire site in a browser, all I see is the background of the site. Everything else is missing, same thing happens when I try to publish the site as a testsite, just the background appears. The active panel shows as connected. Can someone help me with this?

    Hi there, as we have seen most e-mail/case is an orphan and a style tag not closed in the metadata of the page 'hand Master"Master (in properties-> metadata Page) which are causing the problem. See the following screenshot - http://prntscr.com/331pkz.

    Remove the following line of code from metadata and it should work fine.

  • Detect the app in the background

    How will I know that my request was sent in the background? Is there some kind of listener for it?

    the deactivate method is called

  • -Pop-up message error when I start my computer: "TVAgent.exe - Entry Point not found".

    When I start my computer, the first message when I see my desktop is a pop up that says "TVAgent.exe - entry not found.» The procedure entry point not found PowerReadACValues in the dynamic library POWRPROF.dll. "I try to close it and it appears in the same as spot 10 times and then finally I can close it and it will not reappear. I tried a full sweep of the computer with Norton and it did not come with anything. All my programs and all seem to work fine right after, but I fear that there is something wrong. I am running Windows Vista.

    Hi Csiew42,

    Thank you for visiting Microsoft Answers.

    ·         Which version of Windows Vista is installed on your computer?
    ·         Remember to make changes to the computer recently?
    ·         Who is the manufacturer of your computer?

    I suggest to perform the clean boot and check if you get the error again. Clean boot will start Windows Vista by using a minimal set of drivers and startup programs. This type of boot is known as a "clean boot". A clean boot helps eliminate software conflicts.

    The following link has steps showing how to perform the clean boot: http://support.microsoft.com/kb/929135

    (1) perform the clean boot (check the link to perform the clean boot).

    (2) enable half the services.

    (3) determine if the problem comes back.

    (4) enable half of the startup items.

    (5) determine if the problem comes back.

    (6) repeat the steps above until you discover which program or service is causing the problem.

    After you determine the startup item or the service that is causing the problem, contact the manufacturer of the program to determine if the problem can be solved. Or, run the System Configuration utility, and then click to clear the check box of the element of the problem.

    Note: Please make sure that the computer is configured to start as usual according to step 7 of the article: how to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7: http://support.microsoft.com/kb/929135

    Hope the helps of information. Please post back and we do know.

    Kind regards
    Joel S

  • Why do I see all of my messages, even when not signed in?

    When open a direct mail all the messages. I'm not sign in this computer is share with my family and they can see my messages.

    Hello
     
     
    The question you have posted is better suited for the Windows Live Help support forums. I suggest you send the same on the following link for assistance:

  • I can see the background at the top of firefox.

    My tabs frequently become transparent like the rest of the window. I checked the transparency to enable in the settings of customization because it's how I like it set up and that does not always transparent tabs, all of a sudden for no apparent reason, I don't see that they are more.

    Sometimes inexplicable glitches are a result of incompatibilities for graphics driver. You can reduce these problems by disabling the use of Firefox graphics acceleration hardware.

    You need to restart Firefox for it to take effect, so save any work first (e.g. you compose mail, documents online that you are editing, etc.).

    the button Firefox orange (or the Tools menu) > Options > advanced

    In the mini ' General' tab, uncheck the box for "use hardware acceleration when available.

    If you restart Firefox, is the problem solved (or at least enhanced)?

  • Toast in-app in the background

    In a simple way, I want the app to display the toast for some event when minimize. Is this possible?

    No, you can either update the ActiveFrame with your message...

    http://developer.BlackBerry.com/native/documentation/Cascades/UI/active_frames/

    Or send a notification to the hub...

    http://developer.BlackBerry.com/native/documentation/Cascades/device_comm/notifications/

  • Invoke WebWorks app in the background

    Hello

    I develop an application that must call another application I created. The application that should then be called to start a task update that updates its data in the database. I don't want my application called to be visible to the user. Is this possible? Otherwise, what's my alternative?

    I posted a sample here for opening discussion pushes client-side. Let me know if you have any questions.

    http://supportforums.BlackBerry.com/T5/Web-and-WebWorks-development/client-side-push-Inititator/TD-p...

    EDIT: The receiver push aside customer would be the work in the usual way.

    https://github.com/BlackBerry/BB10-WebWorks-samples/tree/master/pushCapture

  • How to activate the message window to run from published resources

    HI -.

    Can someone tell me how to activate the message window, or something similar, to executing the script trace published resources.

    While I can use the message of the Director IDE window, what I want to do is use it when I execute scripts in time real (published resources).

    So my question is confused or upset the terminology, I apologize.

    I am very new to the use of Director (11.5).

    Thank you very much.

    Bob

    You can consult the help file of the Director for more details (minimum). You will see output in the message window when your code runs a statement 'put' (or 'trace'). However, you can use it as you would the application Message window by execute arbitrary code when you press ENTER at the end of a statement (without comment).

    Your whole project works like a projector or in Shockwave (in a browser)?

  • Using Windows Mail - how to make the smaller Options box so I can see the bottom and be able to act on it?

    Computer is a 32-bit Dell XPS * SP2 Windows Vista (Home Premium), Internet Explorer 9 Panda anti-virus

    Nothing new and NO change has been made.

    Using Windows Mail - how to make the smaller Options box so I can see the bottom and be able to act on it?

    Even when I hide the taskbar I always can't NOT see the background.  Thanks in advance for any help. It drives me crazy.

    Set your resolution to be higher.  Right click on your desktop, go to personalize, then choose the resolution down.  Set it to the highest setting.

  • No preview image when using the filter flow therefore cannot see the changes I make up by clicking on the window of fluidity.  No way of knowing what is happening to the image while it is happening.

    Re: the fluidity in the last update PS CC filter.  When you use the filters of flow, how can I see the changes that I do while I'm using the filter tools, as I've always been able to do before?  Now, if I use the tool dilation or contraction tool, etc., I can't see the effect of what I did until I click on the window of fluidity and make to the main screen of PS.  This makes the tools unnecessary fluidity.

    Also check if see the background is checked.

  • Start the Widget in the background

    Hello

    Is it possible to start a Widget app in the background, when the unit starts as if it was in Java applications using the entry point?

    Kind regards

    Nallo

    Hi all

    Here are the steps that I use to configure a widget to auto-run using VS 2008.  It seems to work with simulators as well as when the widget is deployed through BES 5.0.   Please try it and let me know if it works for you.

    1. Create a new BlackBerry Widget project in VS 2008.  Name it "AutoRunWidget".
    2. Build the solution with the Build-> order generate the Solution or F6.
    3. Use windows Explorer to navigate to the project folder and the forest down to the bin\OTAInstall folder.
    4. Find the AutoRunWidget.jad file in the OTAInstall folder.
    5. Right-click on the AutoRunWidget.jad file and select the copy"" command.
    6. Navigate to the top of two levels in the main project folder (one of the contains index.htm and config.xml).
    7. Paste the AutoRunWidget.jad file in the main project folder.
    8. In VS 2008 solution Explorer, click the button "show all files".  You should now see the file AutoRunWidget.jad previously the file config.xml and index.htm in the list (Fig 1).
    9. Make a right click on the AutoRunWidget.jad element and the select "include in project" menu command (Fig 2).
    10. In the Properties window, change the "Build Action" attribute for the file AutoRunWidget.jad ' Compile ' (Fig 3).
    11. Double-click the AutoRunWidget.jad file to display it in the editor VS 2008.
    12. In the content of the AutoRunWidget.jad file, change the line that reads "RIM-MIDlet-flags-1: 0" to "RIM-MIDlet-flags-1: 1"(Fig. 4). "»
    13. Save and close the AutoRunWidget.jad file.
    14. Clean the solution with the Build-> command clean the Solution.
    15. Rebuild the solution with the Build-> order regenerate the Solution.

    That's all!   Please note that whenever you modify the config.xml file, you will need to repeat steps 4 to 15 so that these changes are reflected in the .jad file.

    Coming up:

    -How to set up a widget to auto-run using Eclipse.

    -How to deploy a widget on the homescreen device instead of the folder "downloads".

    Fig 1.

    Fig 2.

    Fig. 3.

    Fig 4.

Maybe you are looking for

  • I can of most favorite sites I want to keep for quick reference, must I use IE?

    Some bookmarks that worked (VRBO sites for example) is no longer add to Favorites or slip and fall in the bookmarks bar. I wanted to bookmark a State run the railroad in Spain - no dice. IE I would like to do both of the above and previous versions o

  • Can't get Firefox to start after OS updates

    Just did the latest updates on OS - X 10.6.8 and now I can't get Firefox to start. He stands up and says he has problems (the 'annoying' window) and that I should try to close tabs. However, it does not at all, so finally I have to force quit. I try

  • Dates of the Restore Points are one month in advance

    For reasons I don't understand, the date of the day on my computer was changed to one month before the effective date, for example from May 13 to June 13, 2013. As a specialist, I kept getting messages that my Microsoft Security Essentials were outda

  • mspaint shortened

    Dear team of Microsoft and the community I went and downloaded a painting app without realizing that I have mspaint in my PC. The only way I can get it to us, that is if I pass by start-run-mspaint-Ok, but I would add mspaint on my desk. When I enter

  • Change to XP Vista

    Is it possible for me to change from Windows Vista to Windows XP, have many problems of compatibility with my existing software I should use.