Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
287 views
in Technique[技术] by (71.8m points)

ios - How can I simulate app being killed in background?

I'm trying to verify that my app (App1) behaves correctly when it is shut down by the system after it launches another app (App2). Is there any way to simulate or force this behavior?

Telling the simulator to simulate a memory warning while App2 is running doesn't do anything until App1 is brought back to the foreground. Would killing App1 from the debugger simulate the same sequence of app events?

EDIT: My app is placed in the background when it launches a second app to handle a file. This second app then relaunches my app, and I'm trying to verify that my app behaves correctly when the system has shut it down while the second app is executing.

question from:https://stackoverflow.com/questions/14969396/how-can-i-simulate-app-being-killed-in-background

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes, if your app is in the background already. An app killed by the system while in the background is terminated with no warning-- no app delegate methods are called, no state changes are made-- which is exactly what happens when you do a debugger stop while the app is in the background. (This presupposes that you've already put your app in the background by clicking the home button on the simulator or Cmd-Shift-H)

(As @Inafziger notes, you can also get the same effect by using the simulator's interface to force quit the running app.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...