0
如果安装了它,我需要打开shazam(其他安装的应用程序在手机中)的代码。 如何检查shazam是否安装在手机中,如果安装了,我怎样才能从我的应用程序中打开它?如果有任何人有想法请帮助。感谢您的帮助。从我的黑莓应用程序打开shazam
如果安装了它,我需要打开shazam(其他安装的应用程序在手机中)的代码。 如何检查shazam是否安装在手机中,如果安装了,我怎样才能从我的应用程序中打开它?如果有任何人有想法请帮助。感谢您的帮助。从我的黑莓应用程序打开shazam
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);
}
感谢y0rk你的帮助,你的帖子是绝对正确的 – Jisson 2011-03-30 06:47:52