WAP之家:为您提供最全最新的WAP技术,CP.SP.3G等行业资讯。 WAP之家交流论坛全新开放 点击进入>>
WAP资讯 | 3G动态 | SP动态 | 运营商动态 | 内容商动态 | 制造商动态 | 论坛讨论>> 每次自动访问
WAP技术 | WAP源码 | 手机编程 | 手机源码 | 无线技术 | J2ME技术 | 手机软件 添加到收藏夹
IVR技术 | SP资料 | SMS MMS技术 | 商业方案 | IVR下载 | 书籍教程 | 工具软件 语言:繁體中文

WAP之家技术文章手机编程BlackBerryBlackBerry 应用程序开发者指南 第二卷:高级--第11章 管理通知(Notification)

BlackBerry 应用程序开发者指南 第二卷:高级--第11章 管理通知(Notification)
作者:佚名  来源:本站整理  发布时间:2008-3-15 2:08:36

 

       private MenuItem triggerItem = new MenuItem(null, 0, 100, 10) {

           public void run() {

              NotificationsManager.triggerImmediateEvent(ID_1, 0, this, null);

              }

           public String toString() {

              return "Trigger event";

              }

           }

       };

      

       private MenuItem deferItem = new MenuItem(null, 0, 100, 10) {

           public void run() {

              long timeout = -1; // Ignored unless trigger is OUT_OF_HOLSTER_TRIGGER.

              int trigger = NotificationsConstants.MANUAL_TRIGGER;

              Object er = new Object();

              NotificationsManager.negotiateDeferredEvent(ID_1, ++_eventIdGenerator,

                     er, timeout, trigger, null);

              }

          

           public String toString() {

              return "Start deferred event";

              }

           };

          

           private MenuItem cancelItem = new MenuItem(null, 0, 100, 10) {

              public void run() {

                  int trigger = NotificationsConstants.MANUAL_TRIGGER;

                  NotificationsManager.cancelDeferredEvent(ID_1, _eventIdGenerator, er,

                         trigger, null);

                  }

              public String toString() {

                  return "Cancel deferred event";

                  }

              };

             

              public void makeMenu( Menu menu, int instance ) {

                  menu.add(triggerItem);

                  menu.add(deferItem);

                  menu.add(cancelItem);

                  super.makeMenu(menu, instance);

                  }

             

              public void onExit() {

                  System.exit(0);

                  }

             

              private static class NotificationsEngineListenerImpl implements

                         NotificationsEngineListener {

                  private UiApplication _app;

                  }

             

              public NotificationsEngineListenerImpl(UiApplication app) {

                  _app = app;

                  }

             

              public void deferredEventWasSuperseded(long sourceID, long eventID,

                     Object eventReference, Object context) {

                  final long _eventID = eventID;

                  er = eventReference;

                  _app.invokeLater(new Runnable() {

                     public void run() {

                         NotificationsManager.cancelDeferredEvent(ID_1, _eventID, er,

                                NotificationsConstants.MANUAL_TRIGGER, null);

                         }

                     });

                  }

             

              public void notificationsEngineStateChanged(int stateInt, long sourceID,

                     long eventID, Object eventReference, Object context) {

                  if(stateInt == NotificationsConstants.OUT_OF_HOLSTER_ENGINE_STATE) {

                     // Perform some action if handheld is removed from holster.

                     }

                  if(stateInt == NotificationsConstants.IN_HOLSTER_ENGINE_STATE) {

                     // Perform some action if handheld is inserted into holster.

                     }

                  }

             

              public void proceedWithDeferredEvent(long sourceID, long eventID,

                     Object eventReference, Object context) {

                  final long _eventID = eventID;

                  }

              _app.invokeLater(new Runnable() {

                  public void run() {

                     String s = "This event has occurred: " + _eventID;

                     Dialog d = new Dialog(Dialog.D_OK, s, Dialog.OK,

                            Bitmap.getPredefinedBitmap(Bitmap.INFORMATION), 0);

                      };

                    

                     private MenuItem cancelItem = new MenuItem(null, 0, 100, 10) {

                         public void run() {

                            int trigger = NotificationsConstants.MANUAL_TRIGGER;

                            NotificationsManager.cancelDeferredEvent(ID_1,

                                   _eventIdGenerator, er,trigger, null);

                            }

                         public String toString() {

                            return "Cancel deferred event";

                            }

                         };

                        

                         public void makeMenu( Menu menu, int instance ) {

                            menu.add(triggerItem);

                            menu.add(deferItem);

                            menu.add(cancelItem);

                            super.makeMenu(menu, instance);

                            }

                        

                         public void onExit() {

                            System.exit(0);

                            }

                        

                         private static class NotificationsEngineListenerImpl

                         implements NotificationsEngineListener {

                            private UiApplication _app;

                            public NotificationsEngineListenerImpl(UiApplication app) {

                                _app = app;

                                }

                           

                            public void deferredEventWasSuperseded(long sourceID,

                                   long eventID,Object eventReference, Object context)

                            {

                                final long _eventID = eventID;

                                er = eventReference;

                                _app.invokeLater(new Runnable() {

                                   public void run() {

                                       NotificationsManager.cancelDeferredEvent(ID_1,

                                              _eventID, er,

                                              NotificationsConstants.MANUAL_TRIGGER, null);

                                       }

                                   });

                                }

                            public void notificationsEngineStateChanged(int stateInt, long sourceID,

long eventID, Object eventReference, Object context) {

                                if(stateInt == NotificationsConstants.OUT_OF_HOLSTER_ENGINE_STATE) {

                                   // Perform some action if handheld is removed from holster.

                                   }

                                if(stateInt == NotificationsConstants.IN_HOLSTER_ENGINE_STATE) {

                                   // Perform some action if handheld is inserted into holster.

                                   }

                                }

                           

                            public void proceedWithDeferredEvent(long sourceID, long eventID,

                                   Object eventReference, Object context) {

                                final long _eventID = eventID;

                                _app.invokeLater(new Runnable() {

                                   public void run() {

                                       String s = "This event has occurred: " + _eventID;

                                       Dialog d = new Dialog(Dialog.D_OK, s, Dialog.OK,

                                              Bitmap.getPredefinedBitmap(Bitmap.INFORMATION), 0);

                                       d.show();

                                       }

                                   });

                                }

                            }

                         }

上一页  [1] [2] [3] [4]  下一页

[] [返回上一页] [打 印]
文章评论

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码