从我的黑莓应用程序中打开 Shazam

发布于 2024-10-25 04:08:12 字数 101 浏览 1 评论 0原文

如果安装了 Shazam(手机中其他安装的应用程序),我需要代码打开它。 如何检查手机中是否安装了 shazam,如果安装了,如何从我的应用程序中打开它?如果有人有想法,请帮忙。先谢谢了。

I need the code open shazam(other intalled applications in the phone) if its installed.
How can I check whether shazam is installed in a phone,and if installed how can I open it from my app?If any one have idea please help.Thanks in advace.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请你别敷衍 2024-11-01 04:08:12
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 之类的

int pid=-1;
    if((pid=runApplication(appName))>-1){
            //application running
            System.out.println(appName +" runing with process id "+pid);
        }
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;
}

call runApplication like

int pid=-1;
    if((pid=runApplication(appName))>-1){
            //application running
            System.out.println(appName +" runing with process id "+pid);
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文