Blackberry - How to get the background application process id

In my Blackberry simulator, I run two applications in the background, now I want to get which applications are running in the background. I do not know how to do that. Is it possible to show which applications are running in the background.

+3
source share
3 answers

List and switch of the visible application

alt text http://img195.imageshack.us/img195/7003/applist.png 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]));
    }
}
+7

API RuntimeStore.

, / .

!

+2

Not quite an answer, but the system will not allow me to comment.

You really need to know what running background applications are, or just if your applications are running in the background. If the latter, I think you can build something using the runtime repository

+1
source

Source: https://habr.com/ru/post/1711974/


All Articles