Programmatically dismiss blackberry.ui.toast?

I have a launched a toast with a long delay while a background operation finishes, but I can't find a way to programmatically dismiss the toast when the other task is complete. Is it possible to use the toastId for this?

Hello

Short answer is no. A Toast is an alert dialog box. What you should probably use is an indicator of activity or some sort.

Do you use a framework for your application? Chances are that an activity spinner option is available.

Tags: BlackBerry Developers

Similar Questions

  • Programmatically dismiss an appeal

    Hi guys,.

    I am writing an application that needs to reject a call (because calling a special number is just a "notification" to do something else). I am using the callIncoming for this method and simulate the click on the meu item 'Hang up', like this:

    public void callIncoming(int callId)
    {
        UiApplication.getUiApplication().invokeLater(new Runnable()
        {
            public void run()
            {
                try
                {
                    Menu menu = UiApplication.getUiApplication().getActiveScreen().getMenu(0);
                    for (int i = 0; i <= menu.getSize() - 1; i++)
                    {
                        System.out.println("menu " + i + " :" + menu.getItem(i).getOrdinal() + " - " + menu.getItem(i).toString());
                        if (menu.getItem(i).getOrdinal() == 69632)
                        {
                            menu.getItem(i).run();
                            System.out.println("blocked call");
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.out.println(ex.getMessage());
                }
            }
        });
    }
    

    It works almost well with the Curve 8300 (except for the fact that I still need to close the dialog box 'Missed calls' that appears when I end the call). However, it does not work with the Simulator "BOLD".

    Debug information shows that he finds the following menus:

    menu 0: 4096 - help
    menu 1:70912 - join the Conference
    menu 2:71936 - Mute
    menu 3:77824 - Notes
    menu 4:77840 - back to the phone
    menu 5:1266752 - activate speaker
    6:16982272 menu - Options
    Menu 7:16982273 - status
    Menu 8:268501000 - Switch Application
    Menu 9:268501008 - close

    I tried to use the overloads of invokeLater who takes a delay and the 500 or 1000 specified as a delay, but nothing changes. Even in this case, the executable runs immediately and I get the menu items - there is nothing to 'hang up '!

    Can you explain why is that and a workaround?

    Thank you very much in advance for the help.

    The "BOLD" doesn't have the 'End call' option in the menu.

    I don't know if this is true for all versions > = 4.6.x, but this is true for "BOLD" with 4.6.x. (can someone confirm for other devices on the > = 4.6.x?)

    You can not use this trick more.

    It seems to be:

    (a) RIM did not have this possibility to the developers (their people might have seen discussions of this forum explaining the thing) or

    (b) the policy of the RIM changed for another reason.

    personally, I like having this option in the menu, but it was rarely used.

  • Toast button callback not firing

    When I click on the button of my bread, nothing happens. I'm using the Web Inspector and receives no answer in the console.

    .ajax({
                type: "POST",
                url: "localhost://register.php",
                cache: false,
                dataType:"text",
                data: formData,
                success: function(data, status){
    
            var jsonData = JSON.parse(data);
                showToast();
                }
    ...
    
    function showToast()
    {
    var message = "This is my toast!",
                buttonText = "Click Me",
                toastId,
                onButtonSelected = function () {
                    console.log('Button was clicked for toast: ' + toastId);
                },
                onToastDismissed = function () {
                    console.log('Toast disappeared: ' + toastId);
                },
                options = {
                    buttonText : buttonText,
                    dismissCallback : onToastDismissed,
                    buttonCallback : onButtonSelected
            };
    
            toastId = blackberry.ui.toast.show(message, options);
        }
    

    I just gave it a try with the following steps. The command line (CLI), I performed the following:

    C:\webworks>webworks create toast
    
    C:\webworks>cd toast
    
    C:\webworks\toast>webworks plugin add com.blackberry.ui.toast
    
    C:\webworks\toast>webworks run
    

    Before execution of webworks run, I modified the index.html file in the folder root of www to set the showCustomToast function. I did this right before the call to app.initailize () as follows.

    
    

    Finally, inside index.jswaited deviceready trigger before displaying my bread as follows:

        receivedEvent: function(id) {
            var parentElement = document.getElementById(id);
            var listeningElement = parentElement.querySelector('.listening');
            var receivedElement = parentElement.querySelector('.received');
    
            listeningElement.setAttribute('style', 'display:none;');
            receivedElement.setAttribute('style', 'display:block;');
    
            console.log('Received Event: ' + id);
            showCustomToast();
        }
    

    Since the launch of applications, the bread was displayed, and I could push the button. With the confirmed Web Inspector, I could see that the events of toasts were fired:

    Received Event: deviceready index.js:47
    Button was clicked for toast: 1 index.html:44
    Toast disappeared: 1 index.html:47
    

    Could you try these steps and confirm if you see the same thing?

    Note that once your application is launched, you may not be not able to connect Web Inspector in time. You can work around this problem by inserting an alert('halt'); before the call to showCustomToastand connection Web Inspector before clearing the alert.

    Or, once connected Web Inspector, you can press ctrl + r in the Web Inspector to reload the page, allowing the console to all in the boot log, including events of toast.

  • Sample code for OS 10 for installation and upgrading applications programmatically

    How to install an application programmatically on BlackBerry OS 10?

    For BlackBerry Java OS (until 7 of the BONE), we have this great article how to install an application programmatically:

    http://supportforums.BlackBerry.com/T5/Java-development/programmatically-install-and-upgrade-Applica...

    We use to distribute internal business applications. It is an essential feature for businesses. But of course it works different in BlackBerry OS 10.

    I can't find a similar API for BlackBerry OS 10. I would be grateful if someone could point me to the API which is similar to the former CodeModuleManager and CodeModuleGroup that allows to install applications programmatically. Is there a similar article like the one mentioned above that works for OS 10 and PlayBook?

    Thanks in advance!

    There is no api to do this all downloads are handled by BBW.

    The closest you could get to what you want to do is plug into the in-app payment API and add features to your core application.

    There are other solutions to see with the sideloading but it is probably too heavy for your users, search the forum for the many other thread similar to your requests.

  • Cannot get toast show

    I'm succesfullt to call $.ajax and can even get an alert javascript to show that it succeeded, but when I try to use toast, nothing happens. I added the plugin to toast and see it in the plugin directory, I also added my config.Xml file.

    Here's my javascript :

    App.init = function () {
    App.utils.metaHack();
    $(document).ready(function() {
    $("#regsubmit").click(function(){
    
    var formData = $("#adduser").serialize();
    alert(formData);
    $.ajax({
    type: "POST",
    url: "http://www.hedonsoft.com/tcob/php/register.php",
    cache: false,
    dataType:"text",
    data: formData,
    success: showCustomToast
    });
    return false;
    });
    });
    $('#landing').live("pagecreate", function(){
    navigator.geolocation.getCurrentPosition(App.getLocation);
    });
    $("#bb_activity").live("pageinit", function(){
    App.page.bb_activity.init();
    });
    $("#togglePage, #togglePageDark").live("pageinit", function(){
    App.page.toggle.init();
    });
    $("#actionBarSample").live("pageinit", function() {
    App.page.actionBarSample.init();
    });
    $('#applicationMenu').live("pageinit", function() {
    App.page.applicationMenu.init();
    });
    }
    function showCustomToast(data, status) {
    if(data=="SUCCESS"){
    var message = 'This is a simple Toast';
    blackberry.ui.toast.show(message);
    }
    }
    

    What Miss me?

    Including these solved the problem.


  • How to increase the duration of a toast?

    need 3 seconds duration?

    // simple toast message
    function showToast1() {
       var message = 'This is a simple Toast';
       blackberry.ui.toast.show(message);
    }
    

    Here is the timeout setting:

    http://developer.BlackBerry.com/HTML5/APIs/BlackBerry.UI.toast.html#.show

  • BlackBerry.UI.menu is not defined

    Hello

    I'm developing an application using the SDK Webworks for BB10 (no playbook).

    I am creating an application menu using the blackberry.ui.menu but webinspector reports it as undefined.

    I'm working on Windows with WebWorks SDK version 1.0.4.11 platform

    I tried console.log (blackberry.ui) and I got:

    Object {toast: object}

    (As I understood my config file blackberry.ui.toast. XML) toast and dialogue are works fine for me, but no menu.

    I found that I have no 'menu' file Webworks SDK path\Framework\ext\

    I have only ui.toast, ui.cover, ui.dialog and ui.contextmenu files. Is this a problem?

    Either by the way, I configured the file config.xml for debugging and here is my file config.xml

        
        
        
        
        
        
        https://getpocket.com" subdomains="true" />
    

    I do posts from ajax to the getpocket domain specified, but all the work is done by local files. I also tried to add access uri * and disabling websecurity, but it doesn't seem to work.

    I'd be happy if someone could guide me where I could go wrong.

    This repository is for WebWorks BBOS and PlayBook. Samples for BB10 are in the BB10-WebWorks-community-samples repository here: https://github.com/blackberry/BB10-WebWorks-Community-Samples

  • There's that one button and a single call back could be defined in a toast using HTML5?

    Dear all, I have read the toast associated documents and ask yourself who is only a button and a single reminder could be set for a toast using HTML5? I want to display three buttons and defined three call back for my bread, is possible? If it is not possible to use the toast to do this, how could do this using another approach? Your comment and suggestion would be very useful. Thank you https://developer.blackberry.com/html5/apis/blackberry.ui.toast.html

    Toasts are really intended to be notifications from style UI components. That's why we provide a button if you want some specific user recommended. But they are not designed to be a notification of modal style.

    If you want to display several options for a user to select, you can use a dialog box according to the following documentation:

    - https://developer.blackberry.com/html5/apis/blackberry.ui.dialog.html

    You can take our HTML and CSS and make your own toast and just show/hide div as you wish if ours is not flexible enough for you.

  • See the selection in the image selected when the use of invokeFilePicker() second time

    Hello

    I use invokeFilepicker() to select images to my Gallery.

    The code I'm usign is like that, and it works fine.

    function openFilepicker() {
    // filepicker options
    var details = {
    mode: blackberry.invoke.card.FILEPICKER_MODE_PICKER_MULTIPLE,
    type: [blackberry.invoke.card.FILEPICKER_TYPE_PICTURE],
    viewMode: blackberry.invoke.card.FILEPICKER_VIEWER_MODE_GRID,
    sortBy: blackberry.invoke.card.FILEPICKER_SORT_BY_NAME,
    sortOrder: blackberry.invoke.card.FILEPICKER_SORT_ORDER_DESCENDING
    };
    blackberry.invoke.card.invokeFilePicker(details, function(path) {
    patharray = path;
    //blackberry.system.setWallpaper('file://' + path);
    showToast('Wallpaper changed!');
    var tempChose = selectedPhotosDiv();
    $('.chat-input-container').prepend(tempChose);
    },
    // cancel callback
    function(reason) {
    showToast("cancelled " + reason);
    },
    // error callback
    function(error) {
    if(error) {
    alert("invoke error " + error);
    } else {
    console.log("invoke success ");
    }
    });
    }
    function showToast(msg) {
    blackberry.ui.toast.show(msg);
    }
    

    Now after selecting images and choice made, I want to again select some pictures more.

    So here, I want to make the selected alreay images selected.

    I already have the list of the table that is selected, but I don't know how to make the selection.

    Waiting for more

    Thank you

    Hi there, I took a quick glance through the docs:
    https://developer.BlackBerry.com/HTML5/APIs/beta/BlackBerry.Invoke.card.filepickeroptions.html

    And AFAIK, the API will not lets you specify a file to be highlighted when the selector is presented. You could present this as a JIRA / fiction asks through the developer Issue Tracker.

  • Existing port BB10 Webworks ask BBOS 6 and above devices

    Hi all

    Please guide me the easy steps to port my app BB10 BBOS 6 and above.

    My applications BB10 has features such as WCF service calls, Parsing XMl and JSON localstorage using format.

    and my file config.xml looks like at

    http://www.BlackBerry.com/ns/widgets"version ="0.9.1.25"rim: header =" "RIM-Widget: RIM / widget" xmlns =""http://www.w3.org/ns/widgets " id ="sow">"
      DIABATE
      LS
      https://github.com/tneil "> MMAD"
     
     
     
     


     
     
     
     
     
     
     
     
     
     


       
     


        
        
        
        
        
     


     
     
     
     
        
        <>ermissions >
            <>Ermit > access_sharedermit >
            <>Ermit > bbm_connectermit >
        <>Ermit > connectionermit >
        <>Ermit > access_pimdomain_calendarsermit >
        ermissions >

    Note:

    (1) is THAT BBOS supports all of these features of the config I am uisng for BB10? If not then how to make it compatible with BBOS

    (2) how much of the business logic and .css changes I need to do

    (3) what will be the structure of the application of the Image etc...

    There is no direct way to just "convert" an app, although there are some things you can do to facilitate the process.

    For example, if simply package you your config.xml into a ZIP file and try to package it with BlackBerry WebWorks 2.3.1.5, package manager will alert you to any function (more precisely the features that do not exist in this version of the SDK WebWorks.)

    For example, try to wrap your config.xml I received:

    [ERROR]         Feature cannot be found in any extension(blackberry.ui.toast)
    [ERROR]         Feature cannot be found in any extension(blackberry.pim.calendar)
    

    Note that the package only will talk one at a time, so there may be additional features that should be deleted.

    For all the features that do not exist, it is best to check the BBOS API documentation to see if there is no official API to replace the functionality:

    https://developer.BlackBerry.com/BBOS/HTML5/

    If not, you can check the existing API to the Community (or create your own native extension) for the functional gaps:

    https://github.com/BlackBerry/WebWorks-community-APIs/tree/master/Smartphone

    If a specific feature cannot be found and there is no extension that you offer this feature, you simply be removed from the application.

    In addition, for any element of config.xml, it is best to check these exist against the documentation here:

    https://developer.BlackBerry.com/BBOS/HTML5/documentation/config_doc_elements.html

    There are also differences in function to keep in mind. For example, in BB10, we rely on the webworksready (1.0) and deviceready (2.0) of the events, so that those who are not applicable to the BBOS.

    Finally, the HTML5 support in 6.0 and 7.0 has been much better than in 5.0, but certainly BlackBerry 10 supports much more than previous versions of BBOS. Basically, for generic elements HTML5 and JavaScript, you should not see a whole lot of questions. But if you use more complicated API (IndexedDB, etc.) it is certainly useful to check the compatibility reference to get an idea of what can/cannot be used.

    https://developer.BlackBerry.com/BBOS/HTML5/documentation/web_references_1986046.html

    Without seeing the application, the amount of business logic and CSS that should be changed depends really. If you use something like BBUI, it is created for fits rather well at BBOS. If you use custom implementations, then he will really vary the complexity.

    The structure of the file remains the same, you still have your config.xml file to the root and your HTML code, images, etc. as of the sisters or contained in subfolders.

  • Can network Mobile be enabled/disabled by programming in BB10?

    Hello

    Please let me know if there is a api to power mobile network programmatically in blackberry 10.

    You cannot programmatically change these settings, but you can invite the user to perform an action and call the application of parameters of network connections:
    http://developer.BlackBerry.com/HTML5/documentation/gold/settings.html

    The real action, however, must be done manually by the user.

  • Save the Photo on the Gallery

    HelloW forum.

    I have a problem with an application that was rejected during the in-depth review process.

    There is a function in which you can develop a character + a photo and save the photo on the gallery. Everythings works fine, but when you try to retrieve the image of the gallery you get an error.

    How can it help me understand why the images cannot be open later?

    Thank you.

    /*functions for saving the image*/function savePhoto(){  var canvas = document.getElementById("fotoTomadaPizarra"); /*the canvas*/  var dataURL = canvas.toDataURL('image/jpeg');    try{      dataURL = dataURL.replace('data:image/jpeg;base64,', '');      saveFile(dataURL, '/accounts/1000/shared/camera/cc'+Date.now()+'.jpg');   }catch(e){   alert(e);}}
    
    function saveFile(savedata, openat, picker, ext) {    blackberry.io.sandbox = false;    if (ext == null) ext = '';    if (picker != 'picker') {        window.webkitRequestFileSystem(window.TEMPORARY, 5 * 1024 * 1024, function (fileSystem) {          fileSystem.root.getFile(openat, {create : true}, function (fileEntry) {             fileEntry.createWriter(function (fileWriter) {                 fileWriter.onwriteend = function () {blackberry.ui.toast.show('Guardado!');};                 fileWriter.onerror = function (fileError) {blackberry.ui.toast.show(fileError);};
    
                  try{                   var blob = new Blob([savedata], {type : 'image/jpeg'});                   fileWriter.write(blob);               }catch(e){alert(e)}              $.mobile.loading('hide');              document.getElementById("loadingDiv").style.display = "none";});},errorHandler);});}else {blackberry.invoke.card.invokeFilePicker({mode: blackberry.invoke.card.FILEPICKER_MODE_SAVER,directory: [openat],viewMode: blackberry.invoke.card.FILEPICKER_VIEWER_MODE_GRID,sortBy: blackberry.invoke.card.FILEPICKER_SORT_BY_NAME,sortOrder: blackberry.invoke.card.FILEPICKER_SORT_ORDER_ASCENDING}, function (path) {window.webkitRequestFileSystem(window.TEMPORARY, 5 * 1024 * 1024, function (fileSystem) {fileSystem.root.getFile(path+'.jpg', {create : true}, function (fileEntry) {fileEntry.createWriter(function (fileWriter) {var blob = new Blob([savedata], {type : 'image/jpeg'});fileWriter.write(blob);fileWriter.onwriteend = function () {blackberry.ui.toast.show('Guardado!');};fileWriter.onerror = function (fileError) {blackberry.ui.toast.show(fileError);};$.mobile.loading('hide');document.getElementById("loadingDiv").style.display = "none";});});});});}}
    

    I got it.

    I don't know exactly where the problem was. but this has been solved by using another library.

    https://github.com/blueimp/JavaScript-canvas-to-BLOB/BLOB/master/js/canvas-to-BLOB.js

    Thank you for your help and your time.

  • getExistingPurchases

    One use getExistingPurchases on 10 of BlackBerry?

    I use OS 10.1.0.4181 on a real device (Z10), and each time the error appears: "the application could not be located inside the cache make peace.", error ID: 3 on the getExistingPurchaseOnFailure function.

    blackberry.payment.getExistingPurchases(true, getExistingPurchasesOnSuccess, getExistingPurchasesOnFailure);
    
    function getExistingPurchasesOnFailure(error) {
        var message = "Error occurred: " + error.errorText + ", " + error.errorID;
        var options = {
            timeout : 1000
        };
        blackberry.ui.toast.show(message, options);
    }
    

    Thanks in advance.

    Solved. Seems if the App is in project pops up this error and can't use this feature if the app isn't Post to sell.

  • Q10 Invocation Framework: citing Email

    I used code below for app Z10 snippets to invoke the email app, but unfortunately they do not work for Q10.

    Any idea?

    blackberry.invoke.card.invokeEmailComposer({)
    Subject: «»,
    body:
    à : « »
    }, function() {}
    BlackBerry.UI.Toast.Show ('Success');
    }, function() {}
    BlackBerry.UI.Toast.Show ('Error');
    });

    BlackBerry.Invoke.Invoke ({}
    target: "sys.pim.uib.email.hybridcomposer."
    Action: "bb.action.SHARE."
    type: "text/plain",
    "" data : "
    }, function() {}
    BlackBerry.UI.Toast.Show ('Success');
    }, function() {}
    BlackBerry.UI.Toast.Show ('Error');
    });

    The reason was that the apps required target had not been included. I've updated to the latest version of the os and it works!

    Updated link: http://developer.blackberry.com/blackberry10devalpha/devalpha_update.html

  • Problem with app painted super-simple paper setting

    I have a simple application, where I'm putting the wallpaper. It was based on the example of Web-works on Github, but instead of using a user supplied photo I use one that is packed in the app.

    Simple I have a button that when clicked calls the following function.

    function setPaper() {}
    blackberry.system.setWallpaper('img/img1.jpg');
    BlackBerry.UI.Toast.Show ("painted paper Set");
    };

    I've posted simple on my Dropbox app if anyone can take a look and help, that it would be much appreciated!

    https://DL.dropbox.com/u/32351813/archive.zip

    Thank you

    P. S.

    I put the following in the config file





    <>ermissions >
    <>Ermit > access_sharedermit >
    <>Ermit > use_cameraermit >
    ermissions >

    Found this one.

    You need to refer to files with

    local: / / /.

Maybe you are looking for