Possible to cancel an Android notification after a few minutes? - android

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.

Related

Tracking screen time in android

for a university project I have to track the screen time of an android smartphone. It's hard to find proper search results, because my search engines do only suggest apps, that already do this for you. I am interested in how these apps do this. I assume, there is a native API on android which supports you with this. Unfortunately, I can't find anything that already does this.
The app is supposed to run a little service which tracks the time of the screen activity and other stuff (like location). It would be great, if someone of you can help me out on where to look for examples and where to find information about the android API.
Edit:
To be a bit more precise: It's about the overall screen time, not about the screen time a specific app has.
Broadcast Actions might be a solution for this,
ACTION_SCREEN_ON
ACTION_SCREEN_OFF
https://developer.android.com/reference/android/content/Intent.html#ACTION_SCREEN_ON
https://developer.android.com/reference/android/content/Intent.html#ACTION_SCREEN_OFF

Android Notifications (HTML5/Hybrid)

I'm in the process of creating an app that has tasks, todo's, calendar events, etc. for android.
However, I have looked for weeks and have not found a way to notify users without knowing Java. I use Intel XDK for development, and it has Push.Mobi stuff.
The thing is though, I can't have my app reliant on a connection to the internet.
The best way to explain my goal is this: Google Calendar and other apps will give you alerts and notifications when a certain time comes. I need to be able to do that, using HTML5 node-webkit.
Is there a way? What is the best way I could go about this?
Notification = Java, is the best way to do it.
After reaf your goal, i think the and repeat the best way, easiest, fastest, and simply way is use Native develpment.
Is Just my opinion and experience.

Starting aFunction() in Android on app startup

This Android app developing business is accelerating the brown-to-grey-color conversion of my hair.
Can someone tell me how I'm supposed to get aFunction() to run when the app starts, seeing as I'm not supposed to make a while(true) inside onCreate()?
I've read the tutorial on Android Developer, several other tutorials, multiple questions on here, but none have answered this, seemingly, simple question. Or, at least I haven't been able to find it - without a doubt because I'm asking the wrong question to the great oracle of Amphitheatre Parkway.
The app is my first homemade non-tutorial app, and I'm attempting to make a speedometer based on GPS (obviously). Basic stuff I guess. It needs to update ever so often which I'm using Thread.sleep() for. Setting up LocationManager, getting location, calculating distance and speed is working. Printing the speed is working. Everything, except making it run, is working (he claims in his naivety).
Android development (and in fact most GUI development) is very different than the console development you may have done in the past. The main difference is that GUIs are event-driven. You typically create what are called "callback methods" which respond to events. This allows the system to do other things rather than waiting for a while(true) loop in your app. I am unfamiliar with using GPS in an Android app. You will need to research what callbacks are necessary to deal with GPS notifications. I suggest starting with Making Your App Location Aware and Location and Maps.

Android VPNService - how do I bring up the 'system-managed dialog' from my activity?

According to this tutorial the only way to disconnect the vpn service is to use the 'system-managed dialog'. This can be done manually by dragging down the notification bar and selecting it from there, however this is not a good solution for my problem.
I need to be able to bring this dialog up from within my app when a 'disconnect' button is pressed, however I can't find any documentation on how to do this.
Can anyone help?
Right now the only public and recommended way to disconnect is unfortunately just through the notification. The functions for disconnecting or even bringing up the dialog are otherwise hidden unfortunately.
Of course, that doesn't necessarily mean that they can't be accessed, but that way lies much pain. I haven't tried this in this specific case, but I have done this in the past, way back, with the music player to find out what was playing (for audio scrobbling). So if you absolutely must find a way to do this, no matter how hacky, then you could try this, but keep in mind that 'ere be dragons - this involves accessing a private API that you are not supposed to. That API could change on a whim between any two given builds of android (not just platform versions either), because it is supposed to be private and internal. You would need to make your code very resilient to failure here, and frankly it'll never be anything more than hacky and a PITA.
Right, all that said, see line 171 in this
That's what you want to do. Except you can't see the things you need, right? So you need this AIDL for the service (and possibly a bit of reflection too, I forget - haven't done this in a long time).
This blog post describes something similar, though not in much detail. It's hard to find things talking about, since it is an incredibly discouraged practice.
I think it is fine just to close tun descript and let the Service end. This will effectlivy end the VPN (but the app in question will still hold the permission to open a VPN again). The notification (key symbol) will also go away. If you are trying the VPNService of another app that might be tougher. Perhaps you should ask the author of that app for an API.

Droid App. GUI - mobile website or native?

I have recently been asked to help put together an Android App, mostly UI for myself.
Knowing nothing about it and even less about Java, I stumbled upon Appcelerator.
I got it all installed, and fought my way through getting the Kitchen Sink app to work, but that's not what I am looking for. So I am hoping some here might know or be experienced with this.
First off, is Appcelerator as good as it appears to me at first glance?
Second, my main task here would be that each time someone places a call, I would like to check the number being dialed and, if it falls under specific circumstances, throw up a modal dialog box with options for the user to select.
Is this something doable in Appcelerator or am I fishing in the wrong pond?
Any info/advice is appreciated.
First off, is Appcelerator as good as it appears to me at first glance?
Here is my answer when somebody asked that yesterday.
Is this something doable in Appcelerator or am I fishing in the wrong pond?
It is not doable in Appcelerator, except perhaps by writing your own Java-based plugin. Even with that I am skeptical -- most of these sort of cross-platform toolkits (e.g., Titanium, PhoneGap) are designed for apps where the UI is point of control, not system-level events like phone calls.

Categories

Resources