android-pendingintent

FLAG_CANCEL_CURRENT or FLAG_UPDATE_CURRENT

笑着哭i 提交于 2019-12-18 04:03:23
问题 My app sets a repeating alarm on user interaction, it might change the interval time set for the broadcast with Alarm Manager. There is not much in the way of extras. Is the update or cancel flag better in this case? Thanks 回答1: If you are not using extras, you don't have to specify any of those flags. They only change how the systems handles extras with a PendingIntent : replace the ones in the current matching (cached by the system PendingIntent ) or cancel it and create a new one. Refer to

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

what is the exact difference between intent and pending intent? [duplicate]

浪尽此生 提交于 2019-12-17 22:10:49
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: What is Pending Intent? I'm confused about intent and pending intent . Can anyone explain what exactly is the difference between both? I've searched on SO, I found this link but it didn't meet with my need : https://stackoverflow.com/questions/5633810/what-is-difference-between-an-intent-and-a-pending-intent. i know Pending intent is an intent which will start later on. Normal intent is started at the time it is

Notification not getting removed on clicking action button even after providing the notification id

冷暖自知 提交于 2019-12-17 20:51:21
问题 I'm delivering a notification which has 2 action buttons namely "Accept" and "Reject". I'm following this Github repo. When user clicks "Accept", certain conditions are checked and the logic is performed accordingly. UPDATE 2.0 - The problem is that upon clicking "Accept" button, operation is happening successfully but the notification isn't disappearing from the status bar because the id generating here: m = (new Random()).nextInt(10000); is different from here: actionIntent.putExtra("id",

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();

PendingIntent does not send Intent extras

前提是你 提交于 2019-12-17 17:33:54
问题 My MainActicity starts RefreshService with a Intent which has a boolean extra called isNextWeek . My RefreshService makes a Notification which starts my MainActivity when the user clicks on it. this looks like this: Log.d("Refresh", "RefreshService got: isNextWeek: " + String.valueOf(isNextWeek)); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.putExtra(MainActivity.IS_NEXT_WEEK, isNextWeek); Log.d("Refresh", "RefreshService put in Intent: isNextWeek: " +

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

How to remove notification from notification bar programmatically in android?

*爱你&永不变心* 提交于 2019-12-17 15:34:36
问题 Anybody have idea how can we remove notification from application programmatically which is called using Pending intent. I have used to cancel notification using following method. AlarmManager am=(AlarmManager)getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(Display.this, TwoAlarmService.class); PendingIntent pi = PendingIntent.getBroadcast(Display.this, AlarmNumber, intent, PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(pi); But problem is notification which fired already

Is it possible to create multiple PendingIntents with the same requestCode and different extras?

ε祈祈猫儿з 提交于 2019-12-17 09:00:09
问题 I'm using AlarmManager to schedule anywhere between 1 and 35 alarms (depending on user input). When the user requests to schedule new alarms, I need to cancel the current alarms, so I create all of my alarms with the same requestCode, defined in a final variable. // clear remaining alarms Intent intentstop = new Intent(this, NDService.class); PendingIntent senderstop = PendingIntent.getService(this, NODIR_REQUESTCODE, intentstop, 0); am.cancel(senderstop); // loop through days if (sched