首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从我的blackberry应用程序打开shazam

从我的blackberry应用程序打开shazam
EN

Stack Overflow用户
提问于 2011-03-22 22:36:24
回答 1查看 237关注 0票数 0

我需要的代码打开shazam(其他安装在手机上的应用程序),如果它安装。我如何检查是否在手机上安装了shazam,如果安装了如何从我的应用程序中打开它?如果有人有想法,请提前help.Thanks。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-03-23 16:20:28

代码语言:javascript
复制
public static ApplicationDescriptor getApplicationDescriptor(String appName) {
    try {
        int[] moduleHandles = CodeModuleManager.getModuleHandles();
        if (moduleHandles != null && moduleHandles.length > 0) {
            for (int i = 0; i < moduleHandles.length; i++) {
                ApplicationDescriptor[] applicationDescriptors = CodeModuleManager.getApplicationDescriptors(moduleHandles[i]);
                if (applicationDescriptors != null && applicationDescriptors.length > 0) {
                    for (int j = 0; j < applicationDescriptors.length; j++) {
                        if (applicationDescriptors[j].getModuleName().toLowerCase().equals(appName.toLowerCase())) {
                            return applicationDescriptors[j];
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        System.out.println("error at getApplicationDescriptor" + e);
    }
    return null;
}

public static int runApplication(String appName) {
    int processId = -1;
    ApplicationDescriptor appDescriptor = getApplicationDescriptor(appName);
    if (appDescriptor != null) {
        //is not null Application installed
        processId = ApplicationManager.getApplicationManager().getProcessId(appDescriptor);
        if (processId == -1) {
            // -1 if application has no process (i.e. is not running).
            try {
                processId = ApplicationManager.getApplicationManager().runApplication(appDescriptor);
            } catch (ApplicationManagerException e) {
                e.printStackTrace();
            }
        }
    }
    return processId;
}

调用runApplication like

代码语言:javascript
复制
int pid=-1;
    if((pid=runApplication(appName))>-1){
            //application running
            System.out.println(appName +" runing with process id "+pid);
        }
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5392923

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档