android


AlarmManager on being cancelled immediately invokes pending intent


So I have a section of code that schedules an alarm as follows
public void scheduleAlarm(){
Log.d("Scheduler","Alarm is being scheduled");
Intent intent = new Intent(AlarmSettings.this, VolumeService.class);
intent.putExtra("MODE", mode);
PendingIntent pintent = PendingIntent.getService(AlarmSettings.this, id, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Log.d("Alarm ID:", String.valueOf(id));
Log.d("Time", "Time was set for today: " + String.valueOf(time));
if(time < System.currentTimeMillis()){
time += (DAY);
Log.d("Time", "Time was set for tomorrow: " + String.valueOf(time));
}
AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarm.set(AlarmManager.RTC_WAKEUP, time, pintent);
}
The service that is being called is as follows
public class VolumeService extends Service{
#Override
public void onCreate() {
super.onCreate();
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
//My Service code goes here and makes changes to some settings
Log.d("Service", "settings have been changed");
return START_NOT_STICKY;
}
#Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
}
and finally the portion of code that is supposed to cancel the alarms (stay with me, I know its lengthy)
//Unschedule the alarm that is getting deleted
Log.d("Unscheduler", "Alarm is being unscheduled");
Intent uIntent = new Intent(AlarmSettings.this, VolumeService.class);
PendingIntent uPintent = PendingIntent.getService(AlarmSettings.this, id, uIntent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager uAlarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
uAlarm.cancel(uPintent);
uPintent.cancel();
Now, my problem is that when the user deletes an alarm and subsequently calls the unschedule portion of the code, the volumeService is immediately called and the settings are changed. However, this defeats the purpose of the user deleting the alarm as they will only delete it to prevent it from firing and changing the settings. I have checked everywhere imaginable over the course of weeks and am just beating my head against the wall. Now that I have posted it on here though, it will be that I have made a very simple mistake. In any case, thanks for the help in advance!
--edit #1--
Removed the line uPintent.cancel() in the unscheduler portion and still doesn't work.

Related Links

How to implement google alerts in android ? Is there any api available?
'TMapView' does not contain a member named 'Location'
React Native SDK runtime permission error
How to Unlock Screen in Nougat and in Lolipop?
Seekbar height differences between API22 and API23
App Crashing due to large string array
AutoCompleteTextView.getText().toString() is null
android download manager with svg
Communication between DialogFragment and Fragment using onActivityResult [duplicate]
Android - ELM327 Bluetooth hangs sometimes
How to set dynamic weight attribute and call another xml files android?
Is it possible to reduce notification time showing in Android?
Create or launch Android emulator from terminal with animations disabled for Espresso testing
Android webView artefacts when scrolling images
start test apk in another apk
How to update onSignalStrength (Signal Strength)

Categories

HOME
go
phantom-dsl
azure-stream-analytics
paraview
c++11
ng-idle
merge
gpu
phpmyadmin
3d
apache-spark-mllib
battery
serialization
pdfbox
aws-cli
dojo
hugo
jquery-ui
arangodb
fabric.io
mel
mautic
why3
jxl
dynatrace
azure-powershell
event-sourcing
entitymanager
pyramid
foreign-keys
oledb
simpleitk
imagemap
dataflow-diagram
string-concatenation
hta
fragment-backstack
underscore.js
recurring-events
powershell-ise
zend-debugger
left-join
turfjs
mailkit
gojs
slacktextviewcontroller
mnist
batching
raft
google-knowledge-graph
nohup
recurrent-neural-network
metawidget
softmax
preloader
microsoft-metro
oim
httr
yii2-api
trojan
wpas
headless
filehandle
avx
docpad
stax
mongodb-php
jtwig
false-sharing
realsense
exim4
phpgrid
java-money
morton-number
canalyzer
slash
airbrake
keyup
aspectj-maven-plugin
mass-assignment
browserify-shim
post-commit-hook
gii
mdichild
twitter-bootstrap-rails
getopt
dtmf
gpars
jquery-1.9
android-icons
wp7test
fb.ui
asplinkbutton
pdfviewer
xcode3.2
garbage
appjs
multiplexing
isa-swizzling
hibernateexception
google-maps-mobile
entity-attribute-value
user-tracking
jquery-tools
webdev.webserver
xui
cdonts
cac
diagrams
uideviceorientation
instantiationexception
easyb
application-verifier
pos-for-.net
web-application-project
firefox-3

Resources

Encrypt Message