Is it possible to flash a flashlight in iPhone when application is background mode? - iphone

Is it possible to flash a flashlight in iPhone when application is background mode?
Please give some suitable suggestion.

Already given the answer similar of your this question, pls see this link at once
Iphone flashlight not working while app is in background
This is a normal behavior.
Apple's sandboxing will not allow you to keep the flash on while your app is in the background.
There is no workaround unless we are talking about a jailbroken app.
Edit:
Apple is very strict on it's system's APIs usage. Especially when it comes to:
- User privacy
- Battery life
- User experience
In the case of the flashlight, the last two items are relevant. Apple will not let an app drain the battery when not in the foreground and iOS users are used to the fact that flashlight, camera, microphone... are immediately disabled when going to the background (with an exception for the microphone in some background modes cases).
To answer the comment on your initial post, iOS controls your hardware. So since Apple decided they don't want the light to stay on when the user closes the app, iOS will just power off the flash when your app goes in the background. Your app has no authority to prevent it.

When in background your application doesn't work or get any messages from the system.
The only cases when this is allowed are:
navigation application
audio player
Internet telephony
Unless you are designing any of the above you can not flash the user with anything.
If you only want to notify the user about something, you can create a notifier that will pop a message in the users window even if your application is in the background or entirely off. the user can click the message and then he will be back to your application

My app is an audio player, so it keeps running in the background. But flashlight works only when it's in the Foreground. No flashlight from the background.

try AVCaptureDevice
AVCaptureDevice

Related

How to set bluetooth communication to run in background

I am working on a medical related app where a medical device interfaces via bluetooth with an iphone. However I cannot figure out how to allow the app to run indefinately in the background. Right now it only communicates when the app is open. I have been reading a lot of questions related to this and I haven't managed to find an answer which fits. I'm sorry if this is a duplicate. Can someone point me in the direction of how to implement this.
ETA - I just got confirmation that this is supposed to be able to go on the App Store.
Did you come across this question: Background time issue for Bluetooth LE app for Iphone 4s
It seems that adding the background mode bluetooth-central (see documentation) can enable your app to run in the background while handling bluetooth events. As noted in the question above though, you could always set background mode to audio and play a blank looping audio track to keep your app alive and responding if you don't need to be on the App Store.

After unlock iPhone application must be active in background

In my application I want that my application being active even after termination of application. I want that when "slide to unlock" my appliaction is launched.
It is possible? How can I do it without jailbreaking & all...
It is a convenience feature for the user. The application is an audio player and should start playing music immediately when the user unlocks his iPhone or speaking a text "Welcome to iPhone" or something like that.
Please clarify more about it that what you want to do. For this you might be use jail broken tools.
Use this link
http://www.redmondpie.com/how-to-unlock-any-jailbroken-iphone-on-any-baseband-and-firmware/
http://www.redmondpie.com/how-to-unlock-any-jailbroken-iphone-on-any-baseband-and-firmware/

Why does my iPhone App continue in the background?

I wrote my first iPhone App, and managed to get it into the App store. I later discovered a bug that happens on a real device but not on my emulator. I have committed a fix (changed plist to prevent app running in background), but I don't really understand why it happened.
My App allows users to record a sound-byte, however while they are recording they can use the iPhone home button to move the app to the background, and then it can keep recording forever if they don't restart the phone or the app does not crash.
My impression from everything I have read, is that this should not happen as you have to ask for background audio specifically if you want to do this, but now it appears to me that you have to ask specifically to disable it.
Could anyone explain this to me?
The iOS App lifecycle is described in Apple's iOS App Programming Guide.
The App is given the opportunity to save data and otherwise stop things that don't need to be running, before being suspended. You can request extra time doing this by using beginBackgroundTaskWithExpirationHandler:.
If you want your app to stop doing its "normal thing" when it is put into the background then you need to detect the App state transition and stop it yourself.

Does the iOS let developers do this?

Let's say the user leaves the phone on the table. (probably on home screen)
A few hours later, he picks it up. And when it does, the iPhone detects the accelerometer, and it rings.
Unfortunately, this is not possible. Once the OS goes to the home screen, applications running in the background have a limited set of options.
Read this article for more information: http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
Not through officially accepted means (i.e. you could do it on a jailbroken phone conceivably). Primarily, you can't run in the background for that purpose. If the app was running in the foreground, you can easily detect motion and perform an activity - but if the phone is left for too long a period without activity, it will sleep.
Unfortunately, the accelerometer is not one of the specified keys in the UIBackgroundModes option in your apps info.plist.
auido, location and voip are the only ones available for now.
short answer: YES
The trick is to make sure the app doesn't get backgrounded when the phone goes to sleep. The other elements like detecting changes in the accelerometer and playing a sound are all standard features.
As for the no sleep solution, it has been asked before, basically is you play a music sample the app will continue running, so perhaps a loop of silence continuously played.
Only if you left an app designed for that purpose running in the foreground.
It won't be possible if your app is running in the background.

Device auto-lock

I have an application in which I want to lock the iPhone programmatically so that the user can't perform any action.
How can I determine the user is not working with the iPhone for some period, and after that period automatically lock the phone?
Such applications are used in all phone devices, where the user can set an auto-lock time and then the device will automatically lock if the user does not handle the device.
How is it done programmatically? Please give me one example of the code so I can perform this easily.
I am new to iPhone programming, and I am struggling in my application. Help me. Thanks in advance.
(For your lock the iphone device through programatic only )
Impossible.
But , you could prevent your phone from locking when your app is running.
[UIApplication sharedApplication].idleTimerDisabled = YES
There is no way to disable the Home Button in iOS using the documented API. The user will always be able to get back to the home screen or close your application using the Home Button.
Even if you find a way do it (which is very unlikely) your app will be definitely rejected from the App Store for a blatant violation of the iOS Human Interface Guidelines. If I were you I would reconsider implementing this behaviour, frankly, it's just not a good idea.
If you're only looking for blocking the the UI of your app, check out the answers to this question, more specifically, check out the incredibly useful MBProgressHUD library: