How can i get background running applications detail in my Application for iOS? - iphone

I want to develop one application which should be monitoring how much application is running on how much time on my I-Phone Device(including internet browsers).
Please share your idea regarding this post.
little similar like this:
https://itunes.apple.com/us/app/system-manager/id455736462?mt=8
thanks

You really can't since Apple has placed very restrictive guidelines on Apps for iOS.
Although with some low level call you might get some running process information.
Because of the sandbox environment you might not be abele to much more information then that.
Also app's in background are suspended if they have no background running flaggs (voip, audio, location or accessory). Also if the system gets low on memory app that are suspended get killed and there memory freed up.
What you can do:
Try the List of All Processes OS X code which
Can we retrieve the applications currently running in iPhone and iPad
But keep in mind the restiction placed on you app by Apple: The iOS Environment, thus that there are app availble in the appstore that do what you want does not mean that you app will be allowed.

Related

iPhone Background Services Development

I am developing an iphone application and I think that it's business logic requires a service to be always running in background.
The service needed is to get the acceleration of the device and notify or perform a certain action when that acceleration becomes a certain value.
Is that allowable in the Apple policies, or is there any idea about a solution?
What cydia development possibilities to help me ?
Dbramhall left out one important thing:
You can't guarantee that your app won't be killed, the OS can kill apps that are in the background at will if it requires more memory.
So if at all possible i wouldn't rely on making sure it can run its process in the background and before you ask "How can i stop this?". Well you shouldn't I've never tried it myself because i don't know the effects it has on the OS.
Also if you stop it from being killed in the Background, if it is going to be on the app store then it won't pass evaluation process, because it breaks the OS
Well, an application can run in the background and Apple perfectly accepts this however the user will obviously be be able to close the application (or should be able to) via the multi-tasking bar and this will end the application. Period.
Apple will not accept an application that runs constantly regardless of whether the user has is in background state as this drains the battery, heats the device etc. So an application can run in the background so long as the user can quit it when close it from the multi-tasking bar however it cannot continue to run after the user closed it via multi-tasking - if it does continue, Apple will reject the application.
Also, see 2.16 of the Apple Store review guidelines: https://developer.apple.com/appstore/resources/approval/guidelines.html#functionality

App Suddenly Closes

Fellow developers. My thanks to you all for your help and suggestions.
My app SafetyKnight has been approved for sale by Apple and I have submitted an inApp Purchase version for approval.
One last 'bug.' When first opening my app, it sometimes quits unexpectedly. Not often. But only rarely sometimes.
Does the MKMap or maybe not strong signal from communications provider cause an app to cut out at start-up?
Any thoughts or suggestions of code I might add to NOT have the app close/crash to enhance the user experience?
Check your app's memory usage during launch and initial view display. The app might be running out of memory if a lot of other Apple processes (or background apps) are running (Mail fetch, music player, etc.). Also make sure you are checking all your error and status return values from your networking code.
From the Organizer, you can access crash reports of any device connected to your computer. Make your application run in debug mode on the device until it crashes and check in debugger where it happens.
Did you handle the low memory notifications in the didReceiveMemoryWarning methods of the relevant UIViewControllers? What is the iOS you are building against?

Does iOS 4 make “Real Multitasking” available to 3rd party developers?

Ever since the first beta came out I’ve been trying to find out if “real” multitasking is possible — i.e. can you put a program in the background and have it hang on to a network connection indefinitely?
I’m thinking about IM or IRC apps, for example. I’ve compiled an app myself on iOS 4, and without changing a thing it appeared to stay running in the background, but for all I know it was just suspended to memory.
The docs say the best you can do is request up to 10 minutes, but in the developer presentation they showed off Skype sitting in the background and then notifying the user that a call was coming in. Does anyone know for sure how this all works?
It appears the answer is no. The API for Skype is a very special case, called the "voip" mode, and requires special behavior, such as marking the socket in use for VoIP.
You can receive alarm notifications in the background (such as time passed). The amount of time you are in the background running state is severely limited by the OS.
Android's background model is complete and in many ways much nicer.
Apple has a guide named "Supporting Multitasking In Your Applications" which you should be able to locate.
Apple's iOS 4 developer docs outline this all very clearly.
When your app is closed or switched away from, it is almost immediately "suspended", meaning the OS freezes the app's state. When the user switches back to your app, your code keeps running just where it kept off. You don't need to add any code to your app to do this, just compile it against OS 4.
The above is true in most cases. There are two reasons the "suspended" model may not apply:
1) If the device starts to run low on memory, the OS will start terminating suspended apps that haven't been switched to in a while, without warning. This is why it's in your best interest for your app to remember it's state as well, so if your app is terminated, then re-opened, the user doesn't really notice because it still returns to right where they left off.
2) Your app uses one of the "background" APIs. These are for audio playback, VoIP services, or location services. In this case, your app is allowed to continue running in the background but only has access to those APIs. Additionally, your app can designate certain long-running tasks as "background tasks" that need to be completed before the app is suspended or terminated, like uploading pictures to Flickr or rendering a video, etc.
The "background task" method doesn't cover pinging servers indefinitely, as there is a time limit for the task, after which it will be forcibly halted. Apps that need that sort of functionality are expected to implement push notifications, just as before.
That should clear this up. All in all I think it's a pretty elegant solution to multitasking on a mobile device.
iOS 4 applications can either be running or suspended. The operating system will try to keep as many requested applications as possible in memory, while all other applications are suspended.
Applications that run in the background can access features such as navigation, audio, and VOIP (but NOT instant messaging). So it looks like you might be out of luck.
-- PC World Multitasking on Apples iPhone 4
It is possible for apps to request background time. Read the docs. I would say it iOS is "controlled multitasking".
You can create a long running background task, I believe these can include networking features. Just have to set the background task flag on the work block.
https://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
the OS can limit exactly how much time you get though... it will tell you when your time is up giving you a chance to cleanup nicely.
iOS 4 has "real" multitasking to some extend. There are two things to consider:
The UI event loop is single tasking. So only the front app executes on the UI event loop. Not a big deal: detach your main code form the UI event loop (maybe you need to redesign your app).
The OS "may" terminate your app if some criteria are met (e.g. low memory).
Currently one of these criteria is that execution time is limited to 10 minutes (real time not cpu time). However I expect this to change and see better criteria for background app termination (I hope to).
Apart from this you can have timers (event loops) in background.
There is no real multitasking in iOS 4.2 even. because apps will only be allowed to finish the task related to states..for small interval of time and then it will be in suspended state.. If you will set background task for long interval of time then... it will behave unexpectedly like no method will be called when you will try to run the app from anywhere..
You may be interested in this blog post that outlines how "multitasking" works in systems such as iPhone OS 4 and Android.
in fact u can do this, although it's not allowed by Apple. u gotta set up a toolchain in ur mac and use some unofficial SDK...
check http://code.google.com/p/iphone-backgrounder/ for more information
You should use the Push Notifications framework for the feature set you are creating!

iPhone System Processes by CPU Rate (top/ps)

What is the best way to programmatically access the processes sorted by cpu rate on the iPhone (similar to that seen in the *nix top command)? sysctl()?
You can use Instruments to do this, open up Instruments (/Developer/Applications/Instruments) and choose iPhone -> Activity Monitor and hit record, it'll give you all the applications running and how much CPU, RAM and everything else they are running.
Obviously this isn't programatically but you only need to worry about the CPU of a single app at a time if your developing and using this you can profile the app in question very easily
I don't believe you can. Applications are sandboxed on the iPHone platform. A rule of thumb on that platform is to just worry about your own application because you can't access much outside of it.

Can I run multiple app in iphone simultaneously

I want to run two app simultaneously, I am using jailbroken phone and dont want to upload that app to the app store.
Is there any way so that I can log phone call time, this can only be done if my "logging app" is running in background.
Please suggest me, how can I do this on jailbroken phone.
Some thing like:http://msdn.microsoft.com/en-us/library/ms884959.aspx (its for windows)
Is this actually a programming question, or are you asking for an app that logs call times?
Assuming the former, you would write a iPhone program that hooks into current phone conversations some way (private APIs? Not sure if this is indeed possible, just assuming.) You would then run your app via Backgrounder or some other wrapper that provided an interface for multiple applications to run at the same time. This usually comes at the cost of increase battery life, depending on how much CPU (and maybe memory?) the backgrounded app consumes.
Backgrounder is available via Cydia, I believe.
Need to include CoreTelephony, will solve the issue