有一个需求,是列出本机所有app,然后点击每个的时候都能打开。
列出的大大已经解决 http://bbs.iosre.com/t/app/428
但是点击打开的时候,我用的是openurl方法,有的app的scheme难以获得就打不开该app了,是不是有一种方法可以保证一定能打开那个app呢?
越狱机上可以实现,未越狱的话应该不行
请问越狱机实现的话是用什么方法呢?
[UIApplication sharedApplication] launchApplicationWithIdentifier:identifier suspended:NO]; 这个私有接口貌似被封了。。
这个方法是SpringBoard里的,不是UIApplication里的,在SpringBoard内部调用应该没问题
哦。那除了这个,还有别的方法吗?
貌似BackBoardServices里还有一种C方法,可以在别的App里直接打开的,具体的我忘记了,你搜搜看
BKSWorkspace?好的谢谢,之前也搜过不过貌似没搜到现成的=。=
我在网上搜了一段代码
void* sbServices = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices", RTLD_LAZY);
int (*SBSLaunchApplicationWithIdentifier)(CFStringRef identifier, Boolean suspended) = dlsym(sbServices, "SBSLaunchApplicationWithIdentifier");
int result = SBSLaunchApplicationWithIdentifier((CFStringRef)bundleId, false);
dlclose(sbServices);
但是make的时候报错
Cannot initialize a variable of type 'int (*)(CFStringRef, Boolean)' with an rvalue of type 'void *'".
请问这段代码有什么问题呢?(sto上面的回复替换dlsym() 为 (int (*)(CFStringRef, Boolean))是不行的。。。)
int (*openApp)(CFStringRef, Boolean);
void *hndl = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices", RTLD_LAZY);
openApp = (int(*)(CFStringRef, Boolean)) dlsym(hndl, "SBSLaunchApplicationWithIdentifier");
openApp(CFSTR("com.apple.iBooks"), FALSE);
dlclose(hndl);
总算可以打开了,但问题是打开很慢,ipad air居然要等4-5秒才有反应才打开。。。怎么破?
这个没法破吧,你试试在SpringBoard里调用那个Objective-C方法,看看速度如何
为什么我运行你的代码还是不能启动呢,难道是越狱才能启动吗?
运行你这段代码 也是打不开 无响应呢
为什么这段代码运行无效果呢 》你是怎么做得哦?