Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suspend the application

Tags:

How can I suspend my application or send a suspend message to my application?

I want to simulate pressing the home button.

like image 566
Doom Avatar asked Mar 19 '11 07:03

Doom


People also ask

What does it mean to suspend an application?

Ans: Suspended Process are those process which has been turned off temporarily. When a process is temporarily suspended then later on it will restart from exactly the same state where it was stopped. So, the state of those processes must be stored somewhere else on your PC.

How do I suspend an application?

Simply find the process in the list that you'd like to suspend, right-click, and choose Suspend from the menu. Once you've done so, you'll notice that the process shows up as suspended, and will be highlighted in dark gray. To resume the process, right-click on it again, and then choose to resume it from the menu.

What suspended mean?

1 : to debar temporarily especially from a privilege, office, or function suspend a student from school. 2a : to cause to stop temporarily suspend bus service. b : to set aside or make temporarily inoperative suspend the rules. 3 : to defer to a later time on specified conditions suspend sentence.


2 Answers

There is a private instance method for UIApplication:

The following code would work, (tested in an iPhone 3GS):

UIApplication *app = [UIApplication sharedApplication]; [app performSelector:@selector(suspend)]; 
like image 159
moligaloo Avatar answered Oct 14 '22 04:10

moligaloo


Quitting your application or sending it to the background programmatically is a violation of the iOS Human Interface Guidelines, which usually doesn't bode well for getting through the review process:

Don’t Quit Programmatically

Never quit an iOS application programmatically because people tend to interpret this as a crash. However, if external circumstances prevent your application from functioning as intended, you need to tell your users about the situation and explain what they can do about it. Depending on how severe the application malfunction is, you have two choices.

Display an attractive screen that describes the problem and suggests a correction. A screen provides feedback that reassures users that there’s nothing wrong with your application. It puts users in control, letting them decide whether they want to take corrective action and continue using your application or press the Home button and open a different application

If only some of your application's features are not working, display either a screen or an alert when people activate the feature. Display the alert only when people try to access the feature that isn’t functioning.

The philosophical reason for this is explained earlier in that document:

People, not applications, should initiate and control actions. Although an application can suggest a course of action or warn about dangerous consequences, it’s usually a mistake for the app to take decision-making away from the user. The best apps find the correct balance between giving people the capabilities they need while helping them avoid dangerous outcomes.

Users feel more in control of an app when behaviors and controls are familiar and predictable. And, when actions are simple and straightforward, users can easily understand and remember them.

People expect to have ample opportunity to cancel an operation before it begins, and they expect to get a chance to confirm their intention to perform a potentially destructive action. Finally, people expect to be able to gracefully stop an operation that’s underway.

There should be no reason that you need to force your application into the background during its operation. It should remain fully functional when displayed onscreen and it should be up to the user when they want to switch away from your application.

like image 32
Brad Larson Avatar answered Oct 14 '22 04:10

Brad Larson