What I mean is, is there a clock in the system that is maintained separately from the clock which is set by the user? I'm curious regarding writing apps that do some function once per day, and how the programmer keeps the user from just setting back the clock and spamming the function.
Look at the answer in this thread here. Looks like thats exactly what you are looking for
Related
OK, so I have done some research and the consensus seems to be that you can't update android:updatePeriodMillis programatically.
It seems that you have to use AlarmManager instead, which seems like using a sledghammer to crack a nut... odd that the API doesn't just let you update the core updatePeriodMillis.
There's always a slight risk with relying on what's out there on the web, since APIs tend to develop and old answers are no longer relevant.
So I'm just checking that this is still the case. For example, the guide at http://developer.android.com/guide/topics/appwidgets/index.html at least hints that it is possible to change the update period of the AppWidgetProvider. When discussing updatePeriodMillis it says:
"You might also allow the user to adjust the frequency in a configuration—some people might want a stock ticker to update every 15 minutes, or maybe only four times a day."
And then goes on to talk about using AlarmManager but apparently only in relation to avoiding waking the device rather than to changing the update period.
Thanks for any help on this.
So I'm just checking that this is still the case.
Yes, it is still the case that you cannot update updatePeriodMillis. Which is too bad, as I'd love to see an updateUpdatePeriodMillis() method. Particularly if this were done via some sort of builder or transaction object, implying that it too might be changed via an updateUpdateUpdatePeriodMillis() method.
:-)
It seems that you have to use AlarmManager instead
You could use JobScheduler on Android 5.0+ as well, though I suspect that you won't like that much either.
You could also allow the user to configure some multiple of updatePeriodMillis, then only do your work every N updates, though this isn't terribly efficient.
Or, you could not update your app widget periodically at all, instead updating it only as needed based on app functionality, rather than based on time. IMHO, this is what most apps should be doing.
I realize that cutting off a notification after an amount of time is odd and unexpected, but I am creating a Phonegap application for a user study group in which this functionality is necessary. I have tried several methods of achieving this through Phonegap background mode plugins but each has there own quirks and would not work reliably due to Android memory management.
What I am thinking now is that I will modify the Android side of this plugin:
https://github.com/katzer/cordova-plugin-local-notifications
To cancel a notification after three minutes since it has triggered. I have talked to the developer of this plugin and he says it's not possible on his end but I don't mind trying to fix it myself. I don't have a lot of Android experience however, and am not sure if I would be wasting my time in trying. Is there any way this would work?
Edit:
I can go into further detail about what I have tried in the past, however I have arrived at the conclusion that these pursuits are dead ends-- They are all Phonegap plugin oriented and do not address the fundamental problem of Android's memory management system killing my running Javascript components that limit notification duration. Because of this, I figured I would change the Android side of my code.
Unfortunately, I have no experience in Android and have so far found learning Android daunting and the framework complex in my early research. It would be a waste of time to research an involved topic like the Android framework if it turns out that I cannot even do what I need to do. This is why I asked if it was possible or not; it is much easier and quicker for someone to tell me 'no', and obviate the need for me to research, than it is for me to research and understand a topic to the point that I can come to the conclusion myself.
It is very easy, there is a cancel method for notifications:
cancel() : - Cancel a previously shown notification
cancelAll () : - Cancel all previously shown notifications.
for example, if i'm playing a game, a trigger will display an alert after a certain time to warn me not playing too much time and should have a rest.
Both android and iphone solution is welcome.
On Android, using the following permission,
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
you can draw views on top of any other application. For example, this is the permission used by the Facebook Home app to draw its chat heads.
Also, this is a system permission, so it does come at a cost.
(Android solution)
You could use AlarmManager with setRepeating function to repeat this task
Check here
Hope it helps :)
Think about it as on an Alarm Clock, which can interrupt your current App, something which is off-course possible.
Regarding Android you might want to read about AlarmManager
As for iPhone you might want to take a look in this Stackoverflow question discussing local notifications.
I'm constantly trying new apps and my phone is getting cluttered with old apps, I no longer use. So, I thought I'd develop a simple app to help me out. There are similar apps, but none does exactly what I want:
I would like to have a list of apps which I've installed in the last month, which I've used X number of times (for easy access: They may be keepers!) as well as those I've not used in Y weeks.
Is there any way to get app usage statistics with Android? I guess ActivityManager might help me to gather that statistics, but is there a way to read just when an app has been used last? Or how many times in a given period?
Any tips will be most welcome :)
You can try out my app for uninstallation of the apps you don't need : https://play.google.com/store/apps/details?id=com.lb.app_manager .
Also, if you wish to find exact usage statistics of your apps, you can use my app this way: find "settings" (the app itself) inside the list (you can perform a search query), choose to make a shortcut of it, and then choose on the dialog "Usage Statistics". This way you can perform both the operations you wanted.
I also plan on adding this feature somehow in the future, but that's what you can do for now.
Here's a screenshot (it's the first on what I show here) :
Get all alarms saved in the alarm application here I have read there is no common interface to get all alarms in the system, due to different implementations of diverse clock apps.
Is this REALLY true ?! I think it is not possible to have no standard for such a crucial things like alarms ?
Is there no possibility for creating a universal widget that displays 5 next alarms regardles of the clock aplication ?
Is this REALLY true ?!
Yes.
I think it is not possible to have no standard for such a crucial things like alarms ?
If you are aware of any OS ever written that forced alarm clock developers to implement some common API, please point it out. AFAIK, this has never been a requirement since the dawn of the computer.
Is there no possibility for creating a universal widget that displays 5 next alarms regardles of the clock aplication ?
You could threaten all alarm clock application developers at gunpoint to implement your desired API. This may be illegal in some jurisdictions.
Or, you can offer some sort of reward to alarm clock application developers to get them to implement your desired API, such as in the form of cash (directly or indirectly, such as by helping them promote and monetize their apps).
I'm not saying that having such a common API is a bad thing, but developers have the freedom to write what they want. You either need to use carrots, sticks, or both to arrange for common standards, such as an API.