0

I want to take screenshots of any running app, while my app is in the background.

I know I can take screenshots in iOS using:

UIGraphicsBeginImageContext(webview.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

But this is not really possible in a background task as UIGraphicsGetCurrentContext returns NULL and I want a screenshot of the running app and not my view. Is there any other way?

  • Please say more about why you want to do this. Because you're really doing continuous background image processing? Or just to take a snapshot of your view before you get backgrounded? Etc. – Ben Zotto Dec 18 '11 at 00:13
  • Well I want to take screenshots on predefined intervals for testing. The idea is that people could start my app and set an interval. Then start the testing app and my app would take screenshots while they're testing the other app. – user1104019 Dec 18 '11 at 00:18

3 Answers3

3

When running the stock OS, the iOS app security sandbox will prevent your app from having access to the contents of the view of any other app.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • Yeah, thought so as well. I'll give the jailbreaking route a try as we're just developing this testing app for in-house use and not for sale. Just have to wait till 5.0.1 gets an untethered jailbreak... – user1104019 Dec 18 '11 at 11:11
  • Why not include sdks who does that in testing target of your app? – vikingosegundo Feb 27 '15 at 13:29
1

For security reasons, you will not be able to that.

I hope

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
1

Recording the screen from a background app seems to be possible, but not without jailbreaking your device. If you really need this capability for testing, you may find jailbreaking to be worth the hassle, but it's certainly not something you could include in an app that you plan to sell through the App Store.

Caleb
  • 124,013
  • 19
  • 183
  • 272