alarmmanager

My AlarmManager for service update doesn't work

最后都变了- 提交于 2019-12-12 02:45:47
问题 Why my AlarmManager for service update doesn't work? this is my code: public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); startService(); } // Method to start the service public void startService() { startService(new Intent(getBaseContext(), MyService.class)); } // Method to stop the service public void stopService() { stopService(new Intent

Battery is draining because of alarmManager and Broadcast Receiver I think

流过昼夜 提交于 2019-12-12 02:22:09
问题 HI i have an app like a applock (not applock) , which checks for current app running with list of selected apps by a user , if it matches then I hv my code . I have an service which doesnt have any loops calls StartupReceiver .Class(broadcast Receiver) which inturn calls CheckRunningApplicationReceiver.Class(broadcastReceiver) which checks the current activity . I am calling CheckActivity for every 0.5 second . And i do lot of storing and retrieving strings in internal storage inside the

How to pass boolean (or integer) to intent and read it (to detect that my activity was started from Android AlarmManager)?

百般思念 提交于 2019-12-12 02:15:02
问题 I can setup my android app to start at specified time with Android AlarmManager. It works nice, I used this manual and this forum for details (use google translator). So I'm creating DEX file from Java code (from XE7 you can simply attach JAR without creating dex(!)) . To detect if My app was started from AlarmManager I decided to put boolean var to intent, using this java manual from stackoverflow, so I added to java code this line: TestLauncher.putExtra("StartedFromAM", true); Full Java

android - widget AlarmManager repeating too fast

心已入冬 提交于 2019-12-12 02:03:50
问题 I have a widget which shows the data usage, for this I have created a PreferenceActivity where the user can choose from various update frequencies.. I get the chosen freq value from SharedPreferences and with that I start an alarm but I get weird result. Here is my AppWidgetProvider: private static PendingIntent pendingIntent = null; ... public void onReceive(Context context, Intent intent) { Log.d("TAG", "receive"); super.onReceive(context, intent); if (CLOCK_WIDGET_UPDATE.equals(intent

Alarm manager: repeating alarm not always fires

别等时光非礼了梦想. 提交于 2019-12-12 01:46:42
问题 I'm trying to develop a kind of reminders system, so user can enter days for reminders (MON, TUE...) and times on which this reminder will fire (only hour and minutes). It can be any day of the week or multiple days of the week. Here is the code for setting these reminders: final AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); for (final Day day: reminder.getDays()) { for (final ReminderTime reminderTime: reminder.getTimes()) { final Calendar calendar =

AlarmManager alarm start when system time is changed by user?

爷,独闯天下 提交于 2019-12-12 01:42:13
问题 i am using AlarmManager class for setting Alarms it is working fine. But if i set alarm like 9pm and current time is 8pm and i changed the system time to 10pm then alarm 9pm alarm start automatically. so to solve this issue i have searched so much but did not found any good answer Please help here is my code for alarm setting final int id = (int) System.currentTimeMillis(); Intent intent = new Intent(this, AlarmReceiver.class); intent.putExtra("requestCode", id); PendingIntent pendingIntent =

Running an IntentService in BroadcastReceiver using AlarmManager

◇◆丶佛笑我妖孽 提交于 2019-12-12 01:38:47
问题 I want to call a Service in my Receiver class which extends BroadcastReceiver but the service didn't start and I got this error: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start receiver com.example.ahmed.service.AlarmReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference In my MainActivity, I call the alarm manager: // Calendar settings for AlarmReceiver Calendar cur

Android - Alarm with Wakelock not launching Service from intent

放肆的年华 提交于 2019-12-12 01:14:39
问题 I am writing an app and am having a bit of trouble with getting my Alarm BroadcastReceiver from starting a desired intent. The code is as follows: public void onReceive(Context context, Intent intent) { Log.d("Alarm:","Running WakeLock"); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, ""); wl.acquire(); WakeMe.wakelock = wl; Log.d("Alarm:","Running Intent (Service)"); Intent i = new

android AlarmManager behavior when application is forced to close

拥有回忆 提交于 2019-12-12 00:50:18
问题 I use AlarmManager to issue local notifications to user. But if I kill my application using Settings->Apps->Stop, alarm manager seems to be destroyed and all the notification icons disappears from status bar. It it normal? The idea of local notifications is to persuade user to start my great app if it's closed. And it seems odd for me that they are being wiped out if I kill the app. 回答1: If you KILL your application you also kill the AlarmManager. There is nothing odd about it. You close the

How to cancel PendingIntent at specific time?

十年热恋 提交于 2019-12-12 00:12:30
问题 AlarmManager works perfectly when I have not declared cancel but do not fire when I declare the cancel .. Here is the code: Calendar c= Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 37); c.set(Calendar.SECOND, 0); Toast.makeText(this, c.getTime().toString(), Toast.LENGTH_LONG).show(); intent = new Intent(TestAlarm.this, TestAlarmService.class); pi = PendingIntent.getService(TestAlarm.this, 1, intent, 0); AlarmManager am = (AlarmManager) getSystemService(ALARM