iOS4 iPhone turn screen off, keep accelerometer on - iphone

I know this has been asked before, but the answers that I see are 2 years back. So I'll rephrase the question: are there any new power management APIs in iOS4 that I can take advantage of to turn off the screen?
-Overlaying a black view on top of an existing view still drives the screen's backlight and refresh rate.
Can I let the device screen timeout normally and then run my app in the background? I need to collect accelerometer data.
Thank you!

As far as I know you can't collect accelerometer data while the phone is locked. Also there are no power management APIs.
I found this for you tho where they give a trick of using proximity sensor but that doesn't seem like a reasonable solution. Enable iPhone accelerometer while screen is locked

Related

GSEventLockDevice couldn't Lock phone properly

I locked the iPhone by calling the method GSEventLockDevice()from GraphicsServices.framework. It's working fine on the iPhone , but after locking the phone the backlight doesn't turn off. It remains lit and it shows the unlock screen.
How can I make the screen turn off immediately after locking?
Why are you doing this. Apple never accept this kind of private framework tasks. It must be jailbreak app. GraphicsServices.framework not deals with backlight and screen ON and OFF state. it just deals with GSEvents and other graphical things. I think you can't do that .
If you are developing for a jailbroken phone you could use GSEventSetBacklightLevel(0); to dim the brightness level.

Several issues considering an iPhone wake-up light app

I want to build an iPhone app, it's a simple concept. You know those wake-up lights, that function as an alarm clock but then with a fading light? That's what I want for an app.
There are two issues: screen locking and brightness setting. First of all, I like to prevent the screen from locking so the wake-up animation is still visible when you actually wake up. Second, I would like to set the brightness of the screen so when sleeping the screen is dim, but when waking the screen fades to a brighter level.
Unfortunately, I read all around the internets which stated that this impossible. You can prevent the app from locking with one single line of code, but you can't set the screen brightness programmatically without using a private api (which is not allowed for publishing).
Is there some sort of work-around to programmatically show the application on the screen when the alarm triggers, circumventing the lock screen? Could this perhaps be achieved with a local notification? Is there some other sort of nifty code to make the screen as dark as possible when sleeping, but putting it back to life (showing the app) when waking?
I hope some bright folks out here can help me out, because so far my concept seems impossible. Mucho kudo's for the chap that can help me out!
Bye,
Reinder
The wake up screen isn't possible using public APIs.
You can simulate turning the brightness down (and back up) in your app by simply painting the entire view black, or using very very dark colors (and displaying no status bar or a black status bar). But note that turning off the auto-lock timer all night may kill the users battery.
Simple answer: what you want is just not possible with the current public APIs of the iOS SDK.

App is fast on 3GS but slow on 3G

I'm new to computer coding and have just finished coding an app and tested it on both 3G and 3GS. On 3GS, it worked as normal as on the simulator. However, when I tried to run it on 3G, the app becomes extremely slow. I'm not sure what's the reason and I hope someone could shed some light on me.
Generally, my app has a couple of view controller classes, with one of them being the title page, one being the main page, one is setting, etc. I used a dissolve to transition from the title page to the main page. But even this simple transition shows un-smooth performance on a 3G! My other part of the app involves zooming in to some images by scaling up the images, switching images by push or dissolve upon receiving touch events, saving photos into photo library and storing and retrieving some photos in a folder and some data in a SQlite database, each showing un-smooth actions.
Compared with some heavy graphic or heavy maths app, I think mine is pretty simple. I totally have no clue why the app would behave so slow and un-smooth that it is barely useful on a 3G. Any help/ direction would be much appreciated. Thanks for helping out.
You might want to try profiling your application with Shark to find out where the performance bottlenecks are.
I don't know how relevant it is to your case, but my game (shameless plug) MultiMaze is quite undemanding graphically, and worked beautifully on my 3GS. But when I tried it on a 3G, the frame rate dropped to a glacial 10-20 fps. I ported the whole code base from CoreGraphics to OpenGL ES, and that made a world of difference. It now runs at the limit (60 fps) on my 3GS and very close to it on the 3G.
Are you using a lot of memory? 3G has 128MB while the 3GS has 256MB RAM.
Are you getting memory warnings? In my debug builds I have an NSLog in didReceiveMemoryWarning so I can see if/when I get warnings.
EDIT: Check the size of your photos, are they resized for the iPhone screen or are they original sized?
OK, finally found the problem and got the solution. The problem was that I have about a dozens of transparent images laying on each other to form my main view. So when in any animation, the system needs to redraw on every single layer and calculate their transparent effect and so on. (actually I'm not quite sure, but that's what I think)
The solution I have is to make a temporary composite view containing of them all, and placing the composite as an image in a full screen view before starting any animation. It delays starting the fade a moment, but the fade itself is a lot smoother now.

How will I have to update how I program for iPhones now with iOS4?

For example, preparing a launch screen of 320 x 480 would have to be changed....
How is that going to work for us? Are programmers always going to have to be submitting a high-res that will be scaled down for old devices such as the iphone 3g?
The size of the screen is basically 4 times on a pixel by pixel basis. So each pixel of your image for example gets boosted to 4.
What this means for you? You don't have to change your App, your app will scale to the hi res screen for you, same with your UI and images within your UI. Of course if you want to take advantage of the better screen quality you will have to submit hi res images.
I haven't looked at going the other way but I believe it would be a similar case.
One exception to this is text. It automatically scales to the higher res for you for free. So text will look super sharp. One problem with this is if your loading image has text based on the original load screen that wouldn't look the same as when the high res text loads.
Strictly speaking, anyone who's seen the documentation on how they're handling this is still under non-disclosure until Monday, when the new iOS ships.
Suffice to say, it's clever. You'll be able to put both high and low-rez versions of ALL your images into your app, and then load them into your app in a way that's totally transparent from the code side. The device will make its own call about which version of the image is appropriate for the kind of screen it's got.
Now that the WWDC 2010 videos are available for free to any registered iPhone developer (or ADC member), I recommend watching Session 134: Optimize your iPhone App for the Retina Display for a full description of what you need to do to support the iPhone 4's new display.

iphone: Sending multitouch from the device to the simulator?

I need to record a video of a multitouch game I'm working on, and I'd like to record it from the simulator. My idea was to send touches from the device to the simulator (like this project does with the accelerometer). Just by googling I haven't found anything like that, but before I start implementing it I thought I'd ask here if anyone knows about an already existing solution.
Just to be clear, I do need full multitouch (up to 5 fingers). The pinch and drag that are available on the simulator are not enough.
Matt Gallagher has a writeup on synthesizing touch events, which might provide what you're looking for, although I've not tested it myself.
Check out iSimulate, it is an application/library pair that allows you to use to multi-touch (up to 5 fingers), the accelerometer, and the GPS in the iPhone Simulator. It takes only few minutes to integrate into your iPhone project.