【问题标题】:Blackberry - How to get the background application process id黑莓 - 如何获取后台应用程序进程 ID
【发布时间】:2010-11-08 14:55:46
【问题描述】:

在我的黑莓模拟器中,我正在后台运行两个应用程序,现在我想检索哪些是在后台运行的应用程序。我不知道该怎么做。是否可以显示哪些是在后台运行的应用程序。

【问题讨论】:

    标签: blackberry integration background-application


    【解决方案1】:

    不是真正的答案,但系统不会让我评论。

    您是否真的需要知道正在运行的后台应用程序是什么,或者您的应用程序是否在后台运行。如果是后者,我想您可以使用运行时商店构建一些东西

    【讨论】:

      【解决方案2】:

      查看RuntimeStore 的 API 参考。

      还有Knowledge Base entry 如何将应用切换到后台/前台。

      祝你好运!

      【讨论】:

        【解决方案3】:

        列出并切换可见应用

        alt text http://img195.imageshack.us/img195/7003/applist.pnglink text http://img32.imageshack.us/img32/9273/applistmenu.png

        代码:

        class Scr extends MainScreen {
        
            ApplicationDescriptor[] mAppDes;
        
            public Scr() {
                listApplications();
            }
        
            void listApplications() {
                ApplicationManager appMan = 
                    ApplicationManager.getApplicationManager();
                mAppDes = appMan.getVisibleApplications();
                add(new LabelField("Visible Applications:"));
                for (int i = 0; i < mAppDes.length; i++) {
                    boolean isFG = appMan.getProcessId(mAppDes[i]) == appMan
                            .getForegroundProcessId();
                    String text = (isFG ? "[F]:" : "[B]") + mAppDes[i].getName();
                    add(new LabelField(text));
                }
            }
        
            protected void makeMenu(Menu menu, int instance) {
                super.makeMenu(menu, instance);
                menu.add(refreshApps);
                makeAppMenuItems(menu);
            }
        
            MenuItem refreshApps = new MenuItem("Refresh", 0, 0) {
                public void run() {
                    deleteAll();
                    listApplications();
                }
            };
        
            class AppMenuItem extends MenuItem {
                ApplicationDescriptor mAppDes;
                public AppMenuItem(ApplicationDescriptor appDes) {
                    super(appDes.getName(), 100000, 100000);
                    mAppDes = appDes;
                }
                public void run() {
                    ApplicationManager appMan = ApplicationManager
                            .getApplicationManager();
                    int processId = appMan.getProcessId(mAppDes);
                    appMan.requestForeground(processId);
                }
            }
        
            void makeAppMenuItems(Menu menu) {
                for (int i = 0, cnt = mAppDes.length; i < cnt; i++)
                    menu.add(new AppMenuItem(mAppDes[i]));
            }
        }
        

        【讨论】:

          猜你喜欢
          • 2011-02-15
          • 1970-01-01
          • 2010-12-30
          • 2010-12-26
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多