Trigger a notification every x days - android

I want to trigger a notification in the status bar every x days(that the user will define in the application). How can i code this ?
Thank you.

AlarmManager was designed for stuff like that.

Assuming you already know how to code an android app, you can see these pages for code examples:
To trigger a notification in the status bar: http://developer.android.com/guide/topics/ui/notifiers/notifications.html
To run the trigger evey x days, you can use AlarmManager: http://developer.android.com/reference/android/app/AlarmManager.html

Related

is there any listener after performing clear notification in android?

Basicly I want to do something after the user clear my notification from the top bar, How do I do that in andorid programmatically?
Basic example or complete code would be nice thanks.
When you create a Notification,setDeleteIntent ,Here is the api:
setDeleteIntent(PendingIntent intent)
Supply a PendingIntent to send when the notification is cleared explicitly by the user.

Difference in ways of maintaining Notifications

What is the difference between the function FLAG_ONGOING_EVENT and FLAG_NO_CLEAR how do they make the Notification behave differently? Do they both make the Notification permanent.
Documentation says :
FLAG_ONGOING_EVENT: Bit to be bitwise-ored into the flags field that should be set if this notification is in reference to something
that is ongoing, like a phone call. It should not be set if this
notification is in reference to something that happened at a
particular point in time, like a missed phone call.
FLAG_NO_CLEAR :Bit to be bitwise-ored into the flags field that should
be set if the notification should not be canceled when the user clicks
the Clear all button.
I think in these words they have different meanings so mixing these flags will give you a permanent notification until your program process ends , if you use just FLAG_ONGOING_EVENT this cause your notification runs until your binding service like phone call ends and it's also cancelable by developer or it can be clear by user and when you mix it with the other, user can't clear it from status bar.

Allow users to disable notifications Android

I don't know if this can be done but I have a scheduler/diary app that allows the user to add/remove items. When the user adds an item, they are given an option to set a notification for either 1 hour, 30 mins, or 15 mins before the event time or else to not be notified. I am using an alarm manager with a broadcast receiver to handle this.
I want to display an option in the app menu to enable/disable notifications; i.e. if an alarm is scheduled to sound in 15 mins it should not happen. How can I implement this?
Take a look at NotificationManager class. When you set your notification you can provide a notification id like this:
mNotificationManager.notify(id, notification)
If you later want to cancel this notification(i.e. like in your case, if a user has selected an option to disable notifications) you would need to use
mNotificationManager.cancel(id)
Or you could use cancelAll() to cancel all notifications:
mNotificationManager.cancelAll ()
Let me know if this helps.

Display light on Notification fired

I want to display light when notification fires in android
i have try with below code but the screen not displays light
if(isBlink) {
notification.ledOffMS=25;
notification.ledOnMS=100;
notification.ledARGB=Color.RED;
notification.flags=notification.flags|Notification.FLAG_SHOW_LIGHTS;
}
I am not sure about your code and logic inside. But following questions may help you to debug.
How do you trigger isBlink ? Is this through some signal handler ?
How notification parameters gets acknowledged once set ? I suppose you are using some timer or loop logic.
Try to receive this notification with the screen off.. I think google have this requirement to show lights on the led.

android: alarm statusicon like the original alarm app?

I am making a alarm app and was just wondering how do I show a alarm icon at the right side of the statusbar like the original alarm app? normal notifications appear in the left side and I cant find anything about this....
Have searched for days and found it now in the alarm source code =)
Intent alarmChanged = new Intent("android.intent.action.ALARM_CHANGED");
alarmChanged.putExtra("alarmSet", true/*false if you want to hide it*/);
context.sendBroadcast(alarmChanged);
SDK applications can only use Notifications, which go on the left side of the status bar. Firmware applications can place icons elsewhere.

Categories

Resources