黑莓 - 如何获得后台应用程序ID [英] Blackberry - How to get the background application process id

查看:213
本文介绍了黑莓 - 如何获得后台应用程序ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的黑莓模拟器I M运行在后台两个应用现在我想以检索这些都是background.I运行不如何做应用程序。是否有可能表明这是在后台运行的应用程序。

In my blackberry simulator i m running two application at the background now i want to retrive which are the application running in the background.I don't how to do. Is it possible to show which are the application running in the background.

推荐答案


  • 要列出所有可见的应用程序使用<一个href=\"http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/system/ApplicationManager.html#getVisibleApplications%28%29\"相对=nofollow> ApplicationManager.getVisibleApplications()

  • 要带来一定的应用前景利用<一个href=\"http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/system/ApplicationManager.html#requestForeground%28int%29\"相对=nofollow> ApplicationManager.requestForeground(进程ID)

List and switch visible application

  • To list all visible applications use ApplicationManager.getVisibleApplications()
  • To bring some application foreground use ApplicationManager.requestForeground(processId)
  • code:

    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]));
        }
    }
    

    这篇关于黑莓 - 如何获得后台应用程序ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆