NotificationsManager.triggerImmediateEvent doesn't care profile?

Hello

I add notification capabilities to our application.  Because all UI interactions are managed within the application itself, I decided to go with triggerImmediateEvent / cancelImmediateEvent suite in NotificationsManager.

What surprised me, this are just my difference caused the LED flashes red, but has not invoked noises / vibrations.  Is this expected behavior?

I know that I can do on my own (Alert.startAudio/startMIDI/startVibrate), but I want to respect the current user profile.  Once again, 4.7 and offers NotificationsManager.isVibrateOnly (), but I need to support some older phones as well.

I even created a small application based on the Notifications Made Easy knowledge base article.  My version allows to cancel events and change the level of notification. Someone at - it care to take a look and see if I'm doing something wrong there?

package com.samples.simpleNotification;

import java.util.Hashtable;

import net.rim.device.api.notification.NotificationsConstants;
import net.rim.device.api.notification.NotificationsManager;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.ObjectChoiceField;
import net.rim.device.api.ui.container.MainScreen;

public final class SimpleNotification extends UiApplication
{
    //The ID for the notification.
    private static final long ID = 0x749cb23a75c60e2dL;  //com.samples.simpleNotification

    //The toString value of this object will be displayed in the user's Profile settings.
    private static Object theSource = new Object()
    {
        public String toString()
        {
            return "Simple Notification";
        }
    };

    public static void main(String[] args)
    {
        if ( args.length > 0 && args[0].equals("gui") )
        {
            //Display the GUI.
            SimpleNotification theApp = new SimpleNotification();
            theApp.enterEventDispatcher();
        }
        else
        {
            //Register the notification.

            //Register the notification.
            NotificationsManager.registerSource(ID, theSource, NotificationsConstants.IMPORTANT);
        }
    }

    public SimpleNotification()
    {
        //A hash table with notification levels in String and integer forms
        final Hashtable notificationLevels = new Hashtable();
        notificationLevels.put("CASUAL", new Integer(NotificationsConstants.CASUAL));
        notificationLevels.put("IMPORTANT", new Integer(NotificationsConstants.IMPORTANT));
        notificationLevels.put("SENSITIVE", new Integer(NotificationsConstants.SENSITIVE));
        notificationLevels.put("CRITICAL", new Integer(NotificationsConstants.CRITICAL));
        notificationLevels.put("DEFAULT", new Integer(NotificationsConstants.DEFAULT_LEVEL));

        final String[] levels = new String[] { "CASUAL", "IMPORTANT", "SENSITIVE", "CRITICAL", "DEFAULT" };

        final ObjectChoiceField levelChoice = new ObjectChoiceField("Choose notification level: ", levels);
        FieldChangeListener levelListener = new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
                String currChoice = levels[levelChoice.getSelectedIndex()];
                int currLevel = ((Integer) notificationLevels.get(currChoice)).intValue();
                NotificationsManager.deregisterSource(ID);
                NotificationsManager.registerSource(ID, theSource, currLevel);
                levelChoice.setDirty(false);
            }
        };
        levelChoice.setChangeListener(levelListener);

        //A MenuItem used to fire the event.
        MenuItem fireEvent = new MenuItem("Trigger Event", 10, 10)
        {
            public void run()
            {
                NotificationsManager.triggerImmediateEvent(ID, 0, null, null);
            }
        };      

        MenuItem cancelEvent = new MenuItem("Cancel Event", 11, 11) {
            public void run() {
                try {
                    NotificationsManager.cancelImmediateEvent(ID, 0, null, null);
                } catch (Exception e) {
                    Dialog.inform(e.toString() + " trying to cancel event");
                }
            }
        };
        MainScreen mainScreen = new MainScreen();
        mainScreen.add(levelChoice);

        mainScreen.addMenuItem(fireEvent);
        mainScreen.addMenuItem(cancelEvent);

        mainScreen.setTitle(new LabelField("Fire an Event From the Menu"));
        pushScreen(mainScreen);
    }
}

In fact, I found that the 'Top' and 'Medium' profile work on shelf - there is a noise. "Normal" and "Vibrate only" not - I had to manually 'Edit profile' and change the 'Simple Notification' profile so that they work.  It seems that the default values for profiles except 'Loud' and 'Medium' is not well defined...

Tags: BlackBerry Developers

Similar Questions

  • (Redirected) Dell doesn't care

    Posted here:
    http://en.community.Dell.com/support-forums/customercare/f/4674/t/19591542.aspx

    Hi Spethmd.

    I'm sorry that you have all of these problems. I wish that repost you this in our Austin based, client care forum. I am sure that you will get help.

    http://en.community.Dell.com/support-forums/customercare/

  • Deploy and host not applied after you restart car profiles

    Just started playing with Auto deploy and profiles of the host, all of this work have to expect one thing.

    The profile of the host is not applied after you restart, the profile is selected but not applied.

    If I choose 'Apply the profile' Server applies the profile, take this into maintenance mode and it works as it should.

    This should not happen automatically after reboot? And what files newspapers can I look to fix this?

    Any help would be appreciated.

    Yes. You can attach a profile - even if the host is a host running VMs - worms and you can take a look if it is already compatible or not, before it is put in maintenance mode and apply the profile settings. You can even attach a profile to a cluster if you do not need to click on all hosts.

  • Why doesn't Adobe doesn't care its users?

    I had technical support take on my computer but unwilling to help with adobe flash and reader because they are free. Don't forget that I have a trail CC, I'm not re-new. I waited for three hours, and when I asked if there was a cc similar he could help me with what he said was no. I am in despair.

    If you need help will open Flash Player and Acrobat Reader, you should try the forums for them.

    Flash Player:
    -------------------

    Downloads: http://www.adobe.com/support/flashplayer/downloads.html

    Installation Forum: http://forums.adobe.com/community/flashplayer/installing_flashplayer

    Using the Forum: http://forums.adobe.com/community/flashplayer/using_flashplayer

    Acrobat Reader:

    --------------------

    DOWNLOAD: Adobe - download Adobe Reader - all versions

    Forums: Acrobat Reader

  • Profiles notification API

    I create an application that uses notifications.

    Under profiles > advanced > (select any profile) > edit, there are products like browser, MMS, calendar, phone, SMS...

    I would like to ask if I can add an article here for my application because I want the user to simply change the settings here. If I can, any advise what API should I use?

    Need help bad!

    OK - I understand your question, I think.

    Launch you your Notification, and the BlackBerry system plays tones and vibrates the phone, regardless of the user defined in the profile. You do not have it in your program.

    So you register your notice, then you fire NotificationsManager.triggerImmediateEvent () when you want the notification to happen.

    The BlackBerry fires sounds, either, according to the current settings for the active profile.

  • How to use profiles that I put?

    in my code when a notification is happen, I want to make my phone ring and vibrate, I put in my profile, where is my code has an error?

    final long long_id = 12345l; create a GUID
    Mon_evenement Object = new Object() {}
    public String toString() {}
    return "mon_evenement";
    }
    };
    NotificationsManager.registerSource (long_id, mon_evenement, NotificationsConstants.IMPORTANT);

    Call NotificationsManager.triggerImmediateEvent (long eventID, eventReference, sourceID long Object, the object context to trigger the notification.

    After the execution of the next line, your application is automatically gets recorded:

    NotificationsManager.registerSource (long_id, mon_evenement, NotificationsConstants.IMPORTANT);

    There after that if you go and change your profile, you can view your application registered, listed in the other category in edit profile page. You must set the profile parameter by selecting your application.

    You can even see the sample application NotificationsDemo available with BlackBerry JDE for better understanding.

  • My profile files are not visible in the Finder (OS x 10.10 & previous). Can I fix?

    Mozilla help site instructions often start by locating the Thunderbird profile files. I see these from within Tbird and with a Terminal command, but not with the Finder. Why not? I think I have the message index corruption, but I can't delete the file index as directed.

    When you select help/troubleshooting information and click on "View file", doesn't the profile folder open in the Finder?

    http://KB.mozillazine.org/Profile_folder_-_Thunderbird#Finding_your_profile

    Rather than delete the msf to index, you can rebuild them by right-clicking on a folder in the folder Repair, TB, properties.

  • Why no CF11 care techniques or white papers?

    I received an email marketing CF11 today from Adobe with the subject: "Adobe ColdFusion 11: much more to discover!  So I clicked on the link at the bottom for white papers and other resources.  I was surprised, there is no data sheets, whitepapers or anything about CF11 here Data sheets and white papers | Adobe ColdFusion 11 family.  Why not?  Makes it seem like Adobe doesn't care.  It is particularly odd given that it is in an email promo specially for CF11 asking me to 'explorer', but there is nothing to explore.  It's comments to the Adobe marketing.  Thanks for listening.

    Hi David,

    The link is now updated. Please check.

    Kind regards

    Anit Kumar

  • Reject a call by program

    Hello

    Is there another way to reject a call by programming using injection of strike?

    Rgds,

    Siva

    Try this code.

    class IncomingCallListener2 extends AbstractPhoneListener
    {
        int callId;
        PhoneCall phoneCall;
        String incomingCallPhoneNumber;
    
        public static final long NOTIFICATIONS_ID_1 = 0xdc5bf2f81374095L; 
    
        IncomingCallListener2()
        {
            Phone.addPhoneListener(this);
        }
    
        public void callIncoming(int callId)
        {
    
            phoneCall = Phone.getCall(callId);
            incomingCallPhoneNumber = phoneCall.getDisplayPhoneNumber();
            //incomingCallPhoneNumber = incomingCallPhoneNumber.substring(7);    
    
                NotificationsManager.registerSource(NOTIFICATIONS_ID_1,
                new Object()
                {
                    public String toString()
                    {
                        return "Profile 1";
                    }
                }
                ,NotificationsConstants.FORCED);
    
                System.out.println("After Firing event1");
                NotificationsManager.registerConsequence(ConsequenceImpl.ID, new ConsequenceImpl());
                System.out.println("After Firing event 2");
                NotificationsManager.triggerImmediateEvent(NOTIFICATIONS_ID_1, 0, this, null);
                System.out.println("After Firing event 3");           
    
            }  
    
            //Event e = new Event(0xbd2350c0dfda2a51L, ++_eventIdGenerator, 500, -1, NotificationsConstants.OUT_OF_HOLSTER_TRIGGER);
            //e.fire();
                   */
        }
    
        }
    
        private static final class ConsequenceImpl implements Consequence, SyncConverter
        {
            public static final long ID = 0xbd2350c0dfda2a51L; //net.rim.samples.device.notificationsdemo.NotificationsDemo.ConsequenceImpl
            private static final int TYPE = 'n' << 24 | 'o' << 16 | 't' << 8 | 'd'; //notd for NotificationsDemo
            private static final byte[] DATA = new byte[] {'m', 'y', '-', 'c', 'o', 'n', 'f', 'i', 'g', '-', 'o', 'b', 'j', 'e', 'c', 't'};
            private static final Configuration CONFIG = new Configuration(DATA);
            Player p = null;
            private static final int VOLUME = 80; //% volume
    
            /**
             * A static inner class, describing the Configuration information for this consequence
             * 

    This implementst the SyncObject interface, although returns a fixed value. */ private static final class Configuration implements SyncObject, Persistable { public byte[] _data; public Configuration(byte[] data) { _data = data; } public int getUID() { return 0; //we're not actually doing any synchronization (vs backup/restore) so we don't care about this value } } public void startNotification(long consequenceID, long sourceID, long eventID, Object configuration, Object context) { EventInjector.KeyCodeEvent ev = new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN, ((char)Keypad.KEY_END), KeypadListener.STATUS_ALT,5000); EventInjector.invokeEvent(ev); } public void stopNotification(long consequenceID, long sourceID, long eventID, Object configuration, Object context) { } /** * It is likely that the following call will return a separate config object for each SourceID, such as data * that describes user set notification settings. However, for this example, we a trivial, arbitrary conifg object */ public Object newConfiguration(long consequenceID, long sourceID, byte profileIndex, int level, Object context) { System.out.println("in newconfiguration method()"); return CONFIG; } /** * Called when there is inbound (from the desktop) data to be converted to object form */ public SyncObject convert(DataBuffer data, int version, int UID) { //it's up to us to write and read the data. we apply a four byte type and a 4 byte length, and then the raw data try { int type = data.readInt(); int length = data.readCompressedInt(); if ( type == TYPE ) { byte[] rawdata = new byte[length]; data.readFully(rawdata); return new Configuration(rawdata); } } catch (EOFException e) { //we've prematurely reached the end of the DataBuffer System.err.println(e); } return null; } public boolean convert(SyncObject object, DataBuffer buffer, int version) { boolean retval = false; if ( object instanceof Configuration ) { Configuration c = (Configuration)object; buffer.writeInt(TYPE); buffer.writeCompressedInt(c._data.length); buffer.write(c._data); retval = true; } return retval; } }

  • Problem in NotificationsDemo sample application supplied with JDE 4.7.0

    When we run NotificationsDemo example application on BlackBerry 9530 Simulator, the application is added in the profile under the heading other than "Notification Demo". With the help of which the user can set the access to his profile for this application.

    But, its not considered in the NotificationsDemo example application anywhere and is not reflect while we call NotificationsManager.triggerImmediateEvent method too. Its only run the code placed inside the startNotification method in the ConsequenceImpl class. How do we alert the specified user profile setting?

    I just next post:

    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&message.ID=28830#M28830

    I've set up ConsequenceImpl, a set of activities inside the startNotification method, which was actually in conflict with the settings of the custom profile "Notifications Demo".

    I had commented the NotificationsManager.registerConsequence method and everything works as expected.

    Thank you

  • Global dialogue - show when the application is in the background

    I have a function that opens a dialog for the user and the user must choose one of two options. The thing is, this function can be called when the user press a certain button, or when the application is in the background. So, to do this, I use the following code:

    synchronized(Application.getEventLock()){
                final Dialog d = new Dialog(Dialog.D_YES_NO, msg,
                        Dialog.NO, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.VERTICAL_SCROLL);
                // So I would identify it as a Dialog
                if ( Application.isEventDispatchThread() ) {
                    // We have the Event Thread, can just show the Dialog
                    UiApplication.getUiApplication().pushModalScreen(d);
                } else {
                    // running in background
                    UiApplication.getUiApplication().invokeAndWait(new Runnable() {
                    public void run() {
                        NotificationsManager.triggerImmediateEvent(ID, 0, null, null);
                        UiApplication.getUiApplication().pushGlobalScreen(d, 1, UiEngine.GLOBAL_MODAL);
                        NotificationsManager.cancelImmediateEvent(ID, 0, null, null);
                        }
                    });
                }
                return ( d.getSelectedValue() == Dialog.YES );
            }
    

    It works very well when the user presses the button that calls this function. However, when the function is called when the application is in the background, nothing happens.

    If you tap on the icon of the app again, it doensn can't have launched, the debugger says the application application forground and if he says so it is already running and doesn't anything. If the application crashes and you can't access.

    How can I solve this problem and make the pop up dialog box to the user evern if the application is not to the point?

    Thank you for your time.

    I had problems with invokeAndWait() gel all that precedes. Unless you really need, I would use invokeLater().

  • Opinion/Alerts help

    So I'm writing a simple alarm style app, and I encountered some problems.  Anyone know the answer to these questions?

    1. the alarm should continue to sound/vibrate/other whatnot until the user intervenes.  I played with the demo of notifications provided by RIM and have it work in the application.  Records of app with the NotificationsManager and the alert plays when I want it.  However... I want the alert that play continuously, not once.  NotificationsConstants contains the CONTINOUS_REPEAT value, but I don't know where that provide as parameter to turn it on.  It does work with the initial method of NotificationsManager.registerSource ().  Anyone know how to implement that?

    2. If I want a shortcut to menu/button to Notifications profile in my application, how I would do this?  Essentially if the user triggers the application in the screen options, how can I provide them with quick access to change their settings for notifications.

    Thanks in advance,

    Shane

    1. you need to create your own clock and call NotificationsManager.triggerImmediateEvent (...)  to repeat the notification.

    2 examples of code to open the Profile Manager

            try
            {
              int moduleHandle = CodeModuleManager.getModuleHandle(  "net_rim_bb_profiles_app" );
              ApplicationDescriptor[] apDes = CodeModuleManager.getApplicationDescriptors( moduleHandle );
              ApplicationManager.getApplicationManager().runApplication( apDes[0] );
            }
            catch ( ApplicationManagerException e )
            {
              // Handle exception here
            }
    
  • Cannot open the NEF in Nikon 1V1 in PS Elements 10 on Mac App store

    I have 10 of PES in the Mac App store version. The files of my Nikon D700 NEF opens fine. My 1V1 Nikon NEF files only.

    Well, the thing with the app store version is that apple doesn't allow developers to set things up to the update that anyway except through the app store (IE, a new version each time, which adobe probably doesn't care to do it just to update the acr). You must manually update the ACR. The information is in this thread:

    http://forums.Adobe.com/message/4106477

    It's for an older version, but you take the path even for the most recent. You can simply install the plug-in itself, if you don't mind not seen lens profiles, etc.

  • IPod Classic 160g shows no music after synchronization.

    I tried reformatting and restoring. Sometimes I can get a few albums will appear on the ipod, mainly purchased itunes music. Almost none of my CD from my library will not work. It's maybe a hard disk problem. I just want to have some opinion or if someone could have the same question. It started after making the mistake of syncing with itunes after the last update. Forgive me for wanting to add new music. Here are my stats hard drive...

    Retracts: 9

    Reallocation: 16376

    Sectors pending: 0

    PowerOn hours: 143

    Start/stop: 47707

    Temp: current 29

    Temp: Min 5 c

    Temp: Max 56 c

    Do not know your stats, but it is not specifically a drive problem hard if your iTunes Store purchased songs to the iPod and your CD songs imported synchronization are not.  iTunes doesn't care of the original source when it syncs the songs.

    Do you use the method to Manage manual (drag and drop songs on iPod in iTunes) or Auto Sync (setting synchronization music )?  You get an error message after synchronization?

    Find one of the songs that will not sync to your iTunes library.  Make a right click on it and read the information.  Tab Info to file window, browse to the location.  It shows a file path to its location on your disk, or does it mean something else there, like iCloud.  Depending on the configuration of your iTunes, it is possible for you to access your songs streaming from Apple servers ("iCloud").  But to synchronize the songs on your iPod, your files must be stored locally on your disk.

    If this isn't the problem and/or your iPod hard drive is defective, you can consider to replace flash storage, in the form of widely available card compact flash or a card SDXC, on an adapter.  The 5th generation and later "classic" iPods, this website contains relevant information.

    https://www.iFlash.xyz/

  • How to create a global inbox for Thunderbird on Windows 10?

    I just installed Windows 10 and Firefox/Thunderbird. On my old system (Windows 7 and Windows Live Mail), I had four e-mail addresses: one is [email protected] and three with [email protected]. Windows Live Mail combined of incoming emails to all four addresses in a combined Inbox. In you bird, can I combine all the incoming mail to these four addresses in a single mailbox in you bird? How?

    For a true global Inbox, you must configure all your accounts to use a POP connection, and in each account, there is a setting to use the global Inbox under local folders. This setting is not available for accounts using IMAP.

    An alternative that can work for you is to simply switch to the view | Records | Unified. It doesn't care if you use POP or IMAP.

    But view | Records | Unread works very well for me. He maintains the separate accounts but collects all new unread messages.

Maybe you are looking for

  • HP Touchsmart G068CL: Install windows 7 on a laptop HP 15-G068CL AMD A8 6410

    The laptop came with 8 windows pre installed and then I upgraded to 10. Since then, the processor has become much slower (not the one he was very fast), but still, want to downgrade to windows 7 and all format. How can I do? Thank you

  • DataFileExport

    Hello I face a problem with the order of DIAdem DataFileExport. Indeed, I would like to export one or more channels from the portal of data in an Excel file. I followed the help and wrote this very simple code: Call DataFileExport ("C:\Documents and

  • help with local wrt54gs single message

    Greetings: I have the wrt54gs v7 router and it keeps on give me that only local message whenever I tried to connect to internet wirelessly... it is also telling me I have no internet connection, what I do, if I unplug the router and plug my modem dsl

  • Screen of blackBerry Smartphones: I don't know what is this icon, Ayuda!

    1. Please look at the picture: 2. Please tell me what this means. 3 give. me suggestions, what I do? Thank you --------------------------------------------------------- 1 Por favor mira the foto: 2 tell me as significant. 3 Lady sugerencias, that hag

  • [ERROR] ISO [DAAPI] =-1: [I2C] could not open the file bus/dev/i2c-1

    I run the lesson 2 TemperatureSensor projectI can detect the BMP180PI@raspberrypi ~/javame81ea/bin $ sudo i2cdetect y 10 1 2 3 4 5 6 7 8 9 a b c d e f00:          -- -- -- -- -- -- -- -- -- -- -- -- --10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --