alarmmanager

show a notification on a particular date and time

十年热恋 提交于 2019-12-01 10:22:10
问题 I need to show a notification on a particular date and time (27-06-2015 13:00). Initially I am showing a toast message. I have created a broadcast receiver to do that. I am calling the pending intent like this - Activity Code - Calendar cal=Calendar.getInstance(); cal.set(Calendar.MONTH,(5)); cal.set(Calendar.YEAR,2015); cal.set(Calendar.DAY_OF_MONTH, 27); cal.set(Calendar.HOUR_OF_DAY,13); cal.set(Calendar.MINUTE,00); Intent myIntent1 = new Intent(this, AlarmBroadCustReciver.class);

NotificationCompat.Builder missing build() method

允我心安 提交于 2019-12-01 07:49:05
I want to do exactly, what he does: Android Notification at time But in my AlarmReceiver class, I have an error: The method build() is undefined for the type NotificationCompat.Builder, at line: mNotificationManager.notify(1, mBuilder.build()); In android developer site is a similar code, but the same error appears( http://developer.android.com/training/notify-user/build-notification.html ). Any help is greatly appreciated. You may be on an older version of the Android Support package. Make sure that your project has a current copy of android-support-v4.jar or android-support-v13.jar in libs/

Broadcast receiver and pending intent : Show a toast

大兔子大兔子 提交于 2019-12-01 06:29:23
The following is the code for an alarm that has to hit the BroadCast Receiver : Intent intentWithData = new Intent(context, TokenActivity.class); intentWithData.putExtra(Constants.ID,id); intentWithData.putExtra(Constants.POSITION, finalI); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 007, intentWithData, 0); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 5000, pendingIntent); The code for the Broadcast receiver is import android.content.Context; import

Does updating app clear sharedpreferences or remove alarms set by the app?

与世无争的帅哥 提交于 2019-12-01 05:40:11
I've published my app in google store and now I want to update it. But I want to be assured that I don't lose stored data in my app shared preferences. I also set some alarm in my app which starts notification, and I don't want to lose them either. I'm not sure how updating app works? does it rewrite these things? Is there anyway that I can test it before I globally publish it? I should mention that the changes I made in this version contain some changes in manifest: I changed targetSdkVersion and minSdkVersion (It used to have minSdk=8 now I've changed it to 4 and added targetsdk=15 ) and I

Broadcast receiver and pending intent : Show a toast

孤者浪人 提交于 2019-12-01 05:17:11
问题 The following is the code for an alarm that has to hit the BroadCast Receiver : Intent intentWithData = new Intent(context, TokenActivity.class); intentWithData.putExtra(Constants.ID,id); intentWithData.putExtra(Constants.POSITION, finalI); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 007, intentWithData, 0); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() +

NotificationCompat.Builder missing build() method

喜夏-厌秋 提交于 2019-12-01 04:38:48
问题 I want to do exactly, what he does: Android Notification at time But in my AlarmReceiver class, I have an error: The method build() is undefined for the type NotificationCompat.Builder, at line: mNotificationManager.notify(1, mBuilder.build()); In android developer site is a similar code, but the same error appears(http://developer.android.com/training/notify-user/build-notification.html). Any help is greatly appreciated. 回答1: You may be on an older version of the Android Support package.

Does updating app clear sharedpreferences or remove alarms set by the app?

有些话、适合烂在心里 提交于 2019-12-01 04:03:40
问题 I've published my app in google store and now I want to update it. But I want to be assured that I don't lose stored data in my app shared preferences. I also set some alarm in my app which starts notification, and I don't want to lose them either. I'm not sure how updating app works? does it rewrite these things? Is there anyway that I can test it before I globally publish it? I should mention that the changes I made in this version contain some changes in manifest: I changed

Can i use AlarmManager with LocalBroadcastManager on android?

北城以北 提交于 2019-12-01 03:07:32
I've got this code: private AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE); private PendingIntent alarmIntent = PendingIntent.getBroadcast(this, 0, new Intent("my action-name"), 0); alarmManager.setInexactRepeating((int)AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + autoUpdateIntervalInMinutes * 60 * 1000, autoUpdateIntervalInMinutes * 60 * 1000, alarmIntent); But I would like to change this for LocalBroadcastManager. Is this possible? No, it is not possible, because LocalBroadcastManager is only for your own process, and AlarmManager

Alarm not getting stopped

非 Y 不嫁゛ 提交于 2019-12-01 02:17:34
I am trying to stop the alarm and checking it whether it stopped or not, but it always returns true means alarm is working. I tried to stop the alarm based on the answer in the link https://stackoverflow.com/a/17616299/1226882 but it doesnt work for me. Please refer the below code Start Alarm public static void startSchedulerAlaram(Context ctx) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); if

BroadcastReceiver (TIME_TICK) dies every night?

放肆的年华 提交于 2019-12-01 01:33:28
I want to write some kind of background-live-ticker app for sports-web-services... I would like my app to be able to call the TIME_TICK all the time. Btw: I also tried to use the AlarmManager, but the problem is the same. But now my problem... I use a Receiver with a Service for the execution part. The Receiver is called every minute correctly after register. But every night the service is terminated and will never be called again. On Android 2.x everything works fine but Android 4.x will stop the Receiver every day... Is there any posibility to keep the app alive on Android 4.x? The Reveiver