I have an android application that gets data from the web such as an event title, location, date and time. I'd like to alert the user when it is time for the event. I've tried using the calendar API but that seems to be quite vague and unsupported by android. Are there any other ways to alert a user when there is an upcoming event based on the date and time I supply? Being able to set an alarm or something would do as well.
Status bar notifications or Toast would be the classic way. Read:
Notifying the User
http://developer.android.com/guide/topics/ui/notifiers/index.html
There are notifications started by a service so your application doesn't need to be running. Inside your Activity you can use Toasts or Dialogs.
Regarding your kind of information you want to provide I recommend to use a notification.
You can schedule notification using the AlarmManager. And notification can be created using NotificationManager.
You can perform the post of notification in an intent service. Schedule the intent that starts your IntentService with AlarmManager and than inplement the post in onHandleIntent() method. Notification body parameters can be passed as intent extras to you service.
Related
I would like to cause an alarm on a remote iphone/android device when the app is running or not running.
How do I achieve it ?
I can only think of Whatsapp/Skype when there is incoming call, its ringing.
Or would it be possible to cause the phone to play a looping alarm sound on Push Notification.
Another very clear example is "Find My iPhone" app which can trigger a loud alarm to an iPhone.
How can I achieve this programmatically on ios and android ?
Its possible using FireBase Notification Services with JobService & FirebaseMessagingService.
Download the FireBase samples from here .Run module "messaging".I tested it and I was able to receive the notification , even in the Application killed state.
To manage events periodically/scheduled you must implement & deploy your Server somewhere.You can also check FireBase Functions (Beta) to easily implement Server.
To show something (Alaram/UI like calling screen) to user start your custom Activity while receiving FireBase notification.Override handleIntent from FirebaseMessagingService.So that you can receive data from your killed/idle Application.
FireBase Service is System Service & it will be always running.Please have a read.
Code snippet
#Override
public void handleIntent(Intent intent) {
super.handleIntent(intent);
// Get Data here
Log.d(TAG, "intent.."+intent.getExtras());
Intent intent1=new Intent(this,MainActivity.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent1);
}
Note : Some devices (Eg; ASUS's Mobile Manager) may reject to start Application's receiver while , Notification arrives.In that case please provide appropriate permissions.
1 possible solution could be schedule alarm event with repeatInterval on receiving push notification.
EDIT
We can create custom notifications using Notification extensions.They are called as soon as notification arrives & we can present customized view with image/video downloading. So you can try there to schedule events.
For iOS, you will need a server to deliver a push notification to your app, where the notification references a custom audio alert to be played. The audio alert has to be included within the app's bundle as stated in Apple docs.
This alert can't be longer than 30 seconds. If you want the alert to be played longer, you can send send another push notification times roughly 30-seconds after and stop sending the alert when a) user open the app or b) you've reached the maximum threshold.
It's generally not good practise to send multiple notification containing the same payload, unless there is a good reason.
I would suggest splitting up this question into two: one for iOS, and another for Android.
I am trying to make a reminder application on Android. I have taken data from the user and saved in a database. How do I trigger an alarm or push notification on user entered date?
To create push notification, you have to register on console API. but I can't post link , because of low reputation and get your own key. Personally I used this tutorial to create and handle push notification.
http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
but I can't understand why do you need it to alarm user.
To implement alarm after some elapsed time, you can create Service:
http://developer.android.com/reference/android/app/Service.html
There you can create your own alarm or use one of the standard. Sorry, I can't provide code example, because your question is too general.
Insert the information into the Calendar application with the appropriate settings and you will get an alarm when the event occurs.
I need to integrate, in my android application, a calendar from which i can set new event.
I know that is possible call the android calendar (using intent), but what I need is slightly different, for this reason:
I need that when the time of the event is reached, some code is started, and no default notification occurs! In other words I want create a custom notification when alarm of event goes off. Maybe I need to use AlarmManager
How can I solve this problem?
If your problem is that you need to launch some kind of intent at a specified time then you can use AlarmManager. It allows you to schedule your application to be run at some point. When an alarm goes off, the Intent that had been registered for it is broadcast by the system.
For More information about AlarmManager, you can check this link : AlarmManager
I have application that needs to show notification in status bar.
I have to set time and date in my app, and on that time and date notification needs to be shown in status bar as somekind of reminder.
I've tried this tutorial, but scheduled event isn't triggered at all.
Is there a way to do this?
I suggest that you use AlarmManager in connection with a SQL database to handle notifications. You could use AlarmManager to schedule alarms which are fetched from your database. You should use a BroadcastReceiver to add alarms when the phone boots in order to handle the situation where the phone is rebooted by the user or system failure.
This howto explains how to use the AlarmManager.
I'm new with Android programming. I'm just wondering whether its possible to set up auto notification. For example, every morning at 8am, the app will send a notification to user about something. Is this possible? Which area/class of Android programming should I look at? Thanks!
You should have a look at the Alarm Manager. You will need to use either of the 'set' methods, and give it a PendingIntent that will perform a broadcast or start an intent service that wakes up just to show the notification. For the broadcast, you will need to have a receiver in your app, that makes a Notification and shows it.