Can I write a c program that actually alerts about my laptop battery? - batterymanager

Is it possible to write in C to get the alert. If yes, what is the concept to be applied to get an alert when my battery goes down by 40% or gets high to 80%?

You have to use Windows API to get the battery information. Please refer to the link: https://msdn.microsoft.com/en-us/library/windows/desktop/aa372659(v=vs.85).aspx
The following ioctls are used to get the battery information
IOCTL_BATTERY_QUERY_INFORMATION
IOCTL_BATTERY_QUERY_STATUS
IOCTL_BATTERY_QUERY_TAG
IOCTL_BATTERY_SET_INFORMATION
GetSystemPowerStatus function is used to get the power status in windows. Refer to the link: https://msdn.microsoft.com/en-us/library/windows/desktop/aa372693(v=vs.85).aspx

Related

iPhone4(s) - my findings of regionMonitoring feature

In my testing, I have found that the results of my tesing regionMonitoring on iPhone4S has been a little under par.
That being said, here's what's happening in my testing:
I try to test by setting an alert for the same location when I drive. Sometimes, the alert goes off right on the dime, but most of the time it does not. I have been wondering about the accuracy of this feature. The feature saves power, which is great, but what good is it if timely updates are not received by the device. It defeats the purpose. In this case the users are going to give bad reviews to the app - because they'll have to switch to startUpdatingLocation which is power hungry
Since I drive around for testing, and because the updates are not received - in time, I believe, the alert does not go off. Is my 50.0m radius too small? I can increase it - but the user will be alerted a little too soon!
The feature relies on user's device being passed by one cell-tower to the next. Therefore, is the user out of luck (for using this feature) if he/she happens to be in area where there are not enough cell towers?
Thoughts? Suggestions?
Regards....
50 meters is pretty aggressive even for GPS on a handheld. Try throwing up a wider net first, then switch to more aggressive location monitoring when you were say, within 500-1000m of the target location.

How to execute a function in background at specific intervals in iOS

I would like for my iOS app when it is in background mode to execute at specific intervals some functions
(What I precisely want to do is to check a URL, and indicate its (int) content as a badge.)
However, I don't know how to have the function executed in the background.
Thanks.
Read about Executing Code in the Background. There is a limited set of things you can do in the background, what you describe not among them unfortunately.
I think you have two options to solve this problem each of them has pros and cons.
First, one is background refresh check the link. Have in mind that it is different for ios 13 and above. You need to define background tasks check here. It takes me some time to understand the background tasks but it seems more logical and easy to manage if you have several tasks. Still, you don't have the full control of when this task will be executed. It depends on how much battery, network and so on your task will use every time. The system will choose what is the best time to run it.
There is one more option, to implement a silent push notification check here.
Here you can implement a good push mechanism for updates but you will depend on network and permission for notifications. Also, you will need a backend for this solution.
You need to define what works best for you.
I think the best option is to use the voip background mode. Here you can find all the required information: how to run background process on the iOS using private APIs to sync email items without jailbreaking the phone
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app
To update the content frequently when the app is in the background might be difficult, Instead, you can wake the app by pushing a silent notification from backend at regular intervals.
For more information check this article also
https://medium.com/#m.imadali10/ios-silent-push-notifications-84009d57794c

What "kernel level C function" does Frenzapp use to detect running iOS processes?

According to this iphonedevsdk.com forum post, Frenzapp uses two methods to detect other apps installed on an iOS device:
UIApplication canOpenUrl: to check
if known custom URL schemas can be
opened
A "kernel level C function",
that is "authorized by apple".
What "kernel level C function" are they using? Where is it documented?
Thanks to Vladamir and Stephen Darlington for commenting and pointing us at what is most likely the answer:
The kernel C function is sysctl()
It's documented on Apple's iOS Developer site
You need to call it with a certain set of arguments to get the list of running processes (ids and strings)
See Vladimir's previous answer or This post for example code
Right, though the process list is both very limited and presupposes that the process is indeed "running" in the background.
The key for discovery is having a large enough inventory of both process names (but the background tasking can only go so far...) and URLhandlers. And only a few companies in the World (if that many) outside of Apple can actually do this well.
And of course, the Springboard has an open-socket protocol that lets the App Store app (and potentially other apps) query whether an app is installed or not... but that's actually a much tougher one to crack.

How to get the CPU usage of iPhone/iPad?

I saw in A+ monitor, it can show CPU Idle, CPU usage, CPU System. Which API should be used to get the these information? I have searched and I use the getloadavg function, but it can only return the CPU usage. Also it is not correctly for it will always be more than 90%.
Thanks!
Most of these can be retrieved using the appropriate sysctl() selectors.

OpenFeint achievements performance

I've decided to integrate OpenFeint into my new game to have achievements and leaderboards.
The game is dynamic and I would like user to be rewarded immediately for some successful results, but as it seems for me, OpenFeint's achievements are a bit sluggish and it shows visual notification only when it receives confirmation from the server.
Is it possible to change something in settings or hack it a little bit to show notification immediately as soon as it checks only local database if the achievement has not been unlocked it?
Not sure if this relates to the Android version of the SDK (which seems even slower), but we couldn't figure out how to make it faster. It was so unacceptably slow that we started developing our own framework that fixes most of open feint's shortcomings and then some. Check out Swarm, it might fit your needs better.
There are several things you can do to more tightly control the timing of these notifications. I'll explain one approach and you can use this as a starting point to explore further on your own. These suggestions apply specifically to iOS apps. One caveat is that these suggestions refer to internal APIs in OFSDK 2.8 for iOS and not ordinarily recommended for high level use and subject to change in future versions.
The first thing I recommend is that you build the sample app with your own product key. Use the standard sample app to experiment before applying the result to your own code.
You are going to get the snappiest response by separating the notification pop-up UI from the process of submitting the achievement. This way you don't have to worry about getting wrapped up in the logic for deciding whether the submission is going just to the local db or is doing the full confirmation on an async network transaction.
See the declaration of "showAchievementNotice" in "OFNotification.h". Performing a search in the sample app, you will see that this is the internal API used for displaying the achievement pop-up when an achievement is earned. It does not actually submit the achievement. You can call this method directly as it is called from "OFAchievementService.mm" to directly control when the message appears. You can then use the following article to disable the pop-up from being called when the actual submission occurs:
http://support.openfeint.com/dev/notification-pop-ups-in-ios/
This gives you complete freedom to call the submission at a later time provided you keep track of the need to do so. For example, you could locally serialize a flag to take care of the actual submission either after the level is done or the next time the app starts up. Don't forget that the user could quit out of a game without cleanly finishing a level.