Sponsored Links
Hi everyone, I am currently setting an alarm to fire off a background service every 2 minutes in order to check my server for certain updates. Now if I start the app and my screen is on and not locked the phone plays the sound I need it to play and opens the activity. Thats great. But the way I need it to happen is if the screen is off and the phone locked I still need it to check every two minutes and I need it to play that sound and open the activity that is needed. This does not happen for some reason. Could someone explain to me why the alarm doesn't function when my app is not "running" (by this i mean the app is marked as a running process but not actually visible to the user) and the screen is off? The code for the timer is below: int alarmType = AlarmManager.RTC_WAKEUP; long timeToRefresh = System.currentTimeMillis() + (120 * 1000); alarm.set(alarmType, timeToRefresh, alarmIntent); The intent code after I set the alarm: if(validAlert == true){ Intent startIntent = new Intent(this, SevereAlert.class); startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startIntent); } I set valid alert a little above. Once the intent gets called to open it is suppose to play a sound and display a listview which like I said works correctly if I start the service from my app but doesn't do a darn thing if the screen is not on. Thank you for your help and your time, Tommy --