alarmmanager

AlarmManager not working

大兔子大兔子 提交于 2019-12-18 03:12:28
问题 I need to start the activity AlarmReceiver after 10 seconds (for example). I need it to be activated without running the app. But whether the app runs or not the AlarmReceiver do not get called. Any suggestions? Intent intent = new Intent(this, AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 111, intent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); //alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() //+

AlarmManager not working

一世执手 提交于 2019-12-18 03:12:11
问题 I need to start the activity AlarmReceiver after 10 seconds (for example). I need it to be activated without running the app. But whether the app runs or not the AlarmReceiver do not get called. Any suggestions? Intent intent = new Intent(this, AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 111, intent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); //alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() //+

How to create different pendingintent so filterEquals() return false?

杀马特。学长 韩版系。学妹 提交于 2019-12-18 03:04:43
问题 I'm using AlarmManager to set up repeating intents but it has caused some little troubles so hope anyone could help. Summary There are 2 pending intents. One runs at 1000 and another runs at 2000 every day. Each contains a row id from the database for identification purpose. The code looks something like this: Intent i = new Intent(mContext, ScheduleReceiver.class); i.putExtra(RuleDBAdapter.KEY_ROWID, (int)taskId); PendingIntent pi =PendingIntent.getBroadcast(...); mAlarmManager.set

Difference between setRepeating and setInexactRepeating of AlarmManager

半腔热情 提交于 2019-12-17 23:17:03
问题 What are the parameters of the following: alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_FIFTEEN_MINUTES, alarmIntent); And of the following: alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, alarmIntent); What is the difference and also how are the two different in terms of functionality? 回答1: Both examples schedule a repeating alarm that will send the given alarmIntent . On both

Service that repeatedly runs a method, after an amount of time

淺唱寂寞╮ 提交于 2019-12-17 19:29:46
问题 I want to create a service, that runs a method after 10 seconds over and over again, until I stop it, even if the app is closed. My attempted code is below package com.example.tauben; import java.util.Timer; import java.util.TimerTask; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.widget.Toast; public class Reminder extends Service { @Override public IBinder onBind(Intent arg0) { return null; } @Override public void onCreate() { TimerTask

How to stop an alarm in android

我与影子孤独终老i 提交于 2019-12-17 18:51:44
问题 In my main activity which has a button in it. In its onclick listener im calling function to set alarm.The alarm is working but iam not able to stop it .Can some one help me MainActivity.java public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.button1).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setalarm();

How to stop an alarm in android

删除回忆录丶 提交于 2019-12-17 18:51:09
问题 In my main activity which has a button in it. In its onclick listener im calling function to set alarm.The alarm is working but iam not able to stop it .Can some one help me MainActivity.java public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.button1).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setalarm();

AlarmManager - How to repeat an alarm at the top of every hour?

徘徊边缘 提交于 2019-12-17 16:11:19
问题 I want for an event to fire every hour (at 5:00, 6:00, 7:00, etc...). I tried with a persistent background service with a thread but it wasn't the right solution because of: battery consumption service termination, due to android memory management So I'm trying with AlarmManager. It works if I set an alarm to fire in X seconds (using "set" method). But how can I repeat an event (using "setRepeating" method) at the top of every hour, until the alarm is canceled? Thanks! 回答1: When you set

How does android compare pending intents

假装没事ソ 提交于 2019-12-17 16:04:40
问题 Documentation for PendingIntent.FLAG_NO_CREATE reads: Flag indicating that if the described PendingIntent does not already exist, then simply return null instead of creating it. My question: What criteria are used to compare PendingIntents? I'm guessing under the hood this flag uses PendingIntent.equals, but I'm not really sure what criteria that function is using. Is it using the action, requestCode, categories, extras (I'm guessing no), etc.? Context: I want to start an alarm with a pending

Android alarm is cancelled after closing the application

半城伤御伤魂 提交于 2019-12-17 10:58:45
问题 I have a problem with AlarmManager, I set the code for scheduling a repeating alarm and after I run the application, the alarm runs fine. Even if I click on Home button (and the application is paused), the alarm still runs on its interval. The problem is if I open the Task Manager and force close the application, then the alarm stops from running. Is this a normal behavior, is there any way to avoid this and keep the alarm running after closing the application? The code is below - the method