Welcome!

Welcome to the official BlackBerry Support Community Forums.

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

inside custom component

Java Development

Reply
Contributor
Posts: 41
Registered: ‎08-28-2011
My Device: 9800
My Carrier: Abc

How to push a notification with schedule time !

Hi everybody,

 

I want to push a notifications such as " Hello new week " on the first day of each week.

And it run auticomally each week.

I have referenced NotificationsDemo by import this project from BB JDE Plugin.

 

public final class NotificationsDemo extends UiApplication
{    
    // com.rim.samples.device.notificationsdemo.NOTIFICATIONS_ID_1
    static final long NOTIFICATIONS_ID_1 = 0xdc5bf2f81374095L; 

    /**
     * Entry point for application.
     * @param args Command-line arguments
     */
    public static void main( String[] args )
    {
        if( args.length > 0 && args[ 0 ].equals( "autostartup" ) )
        {
            NotificationsDemo nd = new NotificationsDemo();
            nd.registerNotificationObjects();
            
            // Keep this instance around for rendering
            // Notification dialogs.
            nd.enterEventDispatcher(); 
        }
        else
        {
            // Start a new app instance for GUI operations.
            new NotificationsDemo().showGui();
        }
    }
    
    /**
     * Displays the NotificationDemoScreen.
     */
    private void showGui()
    {
        // Create a new instance of the application and make the currently
        // running thread the application's event dispatch thread.
        pushScreen( new NotificationsDemoScreen() );
        enterEventDispatcher();
    }
    
    /**
     * Registers this application as the notification manager.
     */
    private void registerNotificationObjects()
    {
        // A source is registered to tell the system that our application will
        // be sending notification events.  This will will cause a new user
        // editable configuration to be added to the Profiles application. 
        NotificationsManager.registerSource( NOTIFICATIONS_ID_1, new Object()
        {
            public String toString()
            {
                return "Notifications Demo";
            }
        }, NotificationsConstants.IMPORTANT );
        
        // Our NotificationsEngineListener implementation will display a dialog
        // to the user when a deferred event is triggered.
        NotificationsManager.registerNotificationsEngineListener( NOTIFICATIONS_ID_1,
                new NotificationsEngineListenerImpl( this ) );        
                
        // Our Consequence implementation will invoked whenever an immediate
        // event occurs.        
        NotificationsManager.registerConsequence(ConsequenceImpl.ID, new ConsequenceImpl());
    }
    
    /**
     * The MainScreen class for our UiApplication. 
     */
    private static class NotificationsDemoScreen extends MainScreen
    {
        private long _eventId;

        // Constructor
        private  NotificationsDemoScreen()
        {
            // Initialize UI components.            
            setTitle( "Notifications Demo" );
            add( new RichTextField( "Trigger notification from menu." ) );
            
             //A menu item to generate immediate and deferred events.
            MenuItem notifyItem = new MenuItem( new StringProvider( "Notify (ID1)" ), 0x230010, 0 );
            notifyItem.setCommand(new Command(new CommandHandler() 
            {
                /**
                 * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata, Object)
                 */
                public void execute(ReadOnlyCommandMetadata metadata, Object context) 
                {
                    int trigger = NotificationsConstants.MANUAL_TRIGGER;

                    // The timeout parameter is IGNORED unless the TRIGGER
                    // is OUT_OF_HOLSTER_TRIGGER.
                    long timeout = -1;

                    Event e = new Event( NotificationsDemo.NOTIFICATIONS_ID_1, _eventId, 500, timeout,
                            trigger );
                    _eventId++;
                    e.fire();
                }
            }));
            addMenuItem( notifyItem );
          
            	
        }
    }
}

 

Follow the code we use menu to turn on LED but I want run without menu. I will auto run.

and How I set the time correctly to push my notifications ?

 

If this is a bad question I am sorry . Hope everybody who can help me spend a litte time for my question ?

Thanks a alot.

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

NgCo_Binh  From Ho Chi Minh, VietNam

Contributor
Posts: 41
Registered: ‎08-28-2011
My Device: 9800
My Carrier: Abc

Re: How to push a notification with schedule time !

Anybody can help me, plz ?

Contributor
Posts: 41
Registered: ‎08-28-2011
My Device: 9800
My Carrier: Abc

Re: How to push a notification with schedule time !

Anyone give me some tips ? so sad:smileysad: