How do I wake up another app before exiting the app?
Last Update:2015-06-23
Source: Internet
Author: User
<span id="Label3"></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;"></span></p></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; font-family: ‘Hiragino Sans GB‘, ‘Microsoft Yahei‘, ‘Helvetica Neue‘, Helvetica, Arial, sans-serif; border: 0px; text-indent: 22px;"><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; font-family: ‘Hiragino Sans GB‘, ‘Microsoft Yahei‘, ‘Helvetica Neue‘, Helvetica, Arial, sans-serif; border: 0px; text-indent: 22px;"><span style="font-family: KaiTi_GB2312; font-size: 18px; line-height: 26px;">Shimen The main contribution, respect the work of the author, please do not reprint.</span></p></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-family: Arial; font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; border: 0px; text-indent: 22px;"><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-family: Arial; font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; border: 0px; text-indent: 22px;"><span style="line-height: 26px;"><span style="color: rgb(119, 119, 119); text-align: center;"><span style="font-family: KaiTi_GB2312; font-size: 18px;">If the article is helpful to you, you are welcome to donate to the author, support the Shimen, donate the amount at random, ^_^</span></span><br></span></p></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-family: Arial; font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; border: 0px; text-indent: 22px;"><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-family: Arial; font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; border: 0px; text-indent: 22px;"><span style="line-height: 26px;"><span style="text-align: center;"><span style="font-family: KaiTi_GB2312; font-size: 18px;"><span style="color: rgb(119, 119, 119);">I want to donate:</span> click Donate</span></span></span></p></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-family: Arial; font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; border: 0px; text-indent: 22px;"><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-family: Arial; font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; border: 0px; text-indent: 22px;"><span style="line-height: 26px;"><span style="color: rgb(119, 119, 119); text-align: center;"><span style="font-family: KaiTi_GB2312; font-size: 18px;">Cocos2d-x source Download: Dot I teleport</span></span></span></p></p><br><p><p></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">The SDK does not provide a way to terminate the Application.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">To terminate the application, the only way Apple recommends is to press the home Button.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><br></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">But the foundation framework integrates the Darwin framework so that we can use the C function exit (0) to terminate Application.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family: KaiTi_GB2312;font-size:18px;"></span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">Uiapplication's OpenURL method is another way to exit the Application.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">When you call the OpenURL method in your code, your app process is terminated (suspended) and the other app is Awakened.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;"></span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">of course, the two exit apps are not the same mechanism and end Result.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">When you exit the program using exit (0), your app does not just exit the foreground, the memory used by the program is Cleared-it's unrecoverable.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">If launch again this app,ios will re-read binary from Disk-this is a brand new app Image.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;"></span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family: KaiTi_GB2312;font-size:18px;">OpenURL is different, It just hangs up your program, which is Recoverable.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family: KaiTi_GB2312;font-size:18px;">Your app just quits from the foreground, but still exists in the Background.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family: KaiTi_GB2312;font-size:18px;">The user can "wake up" it at some point, and your app is back, and the state of the application still wakes up.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family: KaiTi_GB2312;font-size:18px;">of course, If your luck is not good, iOS will completely recycle your app from memory,</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family: KaiTi_GB2312;font-size:18px;">As in exit (0), this is usually the time when system memory is tight.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;"></span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">Both of these methods may need to coexist at some Point.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">For example, we want to wake up another app, such as safari, before the app Exits.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">At the same time we want our app to be the real "exit" and recycle all of the App's memory.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;"><br></span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">This is a "paradox". Because regardless of exit (0) or openurl, once executed, the operating system terminates the execution of the PROCESS.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">As long as you execute any of these statements, the other statement cannot be executed-because the process has been terminated.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;"></span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">But in some cases, this paradox is true through the ingenious use of the multitasking mechanism of ios.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">For example, we can use the following O-C code to achieve this purpose:</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;"></span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">[self performselector: @selector (exitapp) withobject:nil afterdelay:0.5];</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">[[uiapplication Sharedapplication]openurl:</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">[nsurlurlwithstring:@ "appscheme://"];</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;"></span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">The Exitapp method is actually a code exit (0).</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">So they both Coexist.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;"><br></span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">first, we let exit (0) delay for 0.5 seconds before execution, and before that OpenURL of course Executed.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">The Performselector:afterdelay method dispatches a task to execute after a certain time.</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">Of course, this time cannot be too long, ".</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">Because iOS allows the app to still have a "live" time after entering the background, but this time is not too long,</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;">This means that after the execution of the OpenURL method, the app is still alive and there is a chance to perform the scheduled task (that is, exit (0)).</span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;"><br></span></p></p><p style="color: rgb(51, 51, 51); line-height: 26px;"><p style="color: rgb(51, 51, 51); line-height: 26px;"><span style="font-family:KaiTi_GB2312;font-size:18px;"></span></p></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; font-family: ‘Hiragino Sans GB‘, ‘Microsoft Yahei‘, ‘Helvetica Neue‘, Helvetica, Arial, sans-serif; border: 0px; text-indent: 22px;"><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; font-family: ‘Hiragino Sans GB‘, ‘Microsoft Yahei‘, ‘Helvetica Neue‘, Helvetica, Arial, sans-serif; border: 0px; text-indent: 22px;"><span style="font-family: KaiTi_GB2312; font-size: 18px; line-height: 26px;">Shimen The main contribution, respect the work of the author, please do not reprint.</span></p></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-family: Arial; font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; border: 0px; text-indent: 22px;"><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-family: Arial; font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; border: 0px; text-indent: 22px;"><span style="line-height: 26px;"><span style="color: rgb(119, 119, 119); text-align: center;"><span style="font-family: KaiTi_GB2312; font-size: 18px;">If the article is helpful to you, you are welcome to donate to the author, support the Shimen, donate the amount at random, ^_^</span></span><br></span></p></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-family: Arial; font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; border: 0px; text-indent: 22px;"><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-family: Arial; font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; border: 0px; text-indent: 22px;"><span style="line-height: 26px;"><span style="text-align: center;"><span style="font-family: KaiTi_GB2312; font-size: 18px;"><span style="color: rgb(119, 119, 119);">I want to donate:</span> click Donate</span></span></span></p></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-family: Arial; font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; border: 0px; text-indent: 22px;"><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; color: rgb(92, 92, 92); font-family: Arial; font-size: 14px; background-color: rgb(245, 245, 245); line-height: 28px; border: 0px; text-indent: 22px;"><span style="line-height: 26px;"><span style="color: rgb(119, 119, 119); text-align: center;"><span style="font-family: KaiTi_GB2312; font-size: 18px;">Cocos2d-x source Download: Dot I teleport</span></span></span></p></p><p><p></p></p><p><p>How do I wake up another app before exiting the app?</p></p></span>