alarmmanager

Auto Logout of App when in Background

喜你入骨 提交于 2019-12-02 09:45:29
I Have created an app which will log out within 1 Min; when it is running in the background, by employing Alarm Mgr method. However, when I debug and run in on Android based device, nothing happens. I have run some basic diagnostic test and found out that BaseActivity is not being logged in the Logcat. public class BaseActivity extends Activity{ BaseActivity context; private AlarmManager alarmMgr; //TO CALL OUT THE CLASS OF THE ALARM SERVICE private PendingIntent alarmIntent; // FOR TARGET FUNCTION TO PERFORM WITH BROADCASTRECEIVER BaseActivity(){ context=this; } @Override protected void

Android AlarmManager fire at wrong time

核能气质少年 提交于 2019-12-02 09:22:54
My app will set an AlarmManager to fire some event and repeat it on 12:00pm everyday. However, my clients report that the alarm sometimes wake up normally, but sometimes wake up at other time (eg. 10/11pm). Here is the code snippet: Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); if (calendar.get(Calendar.HOUR_OF_DAY) >= 12 && calendar.get(Calendar.MINUTE) > 0) { calendar.add(Calendar.DAY_OF_MONTH, 1); } calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.AM_PM, Calendar.PM);

Context Cannot be Resolved

試著忘記壹切 提交于 2019-12-02 08:57:06
I'm attempting to use a method to schedule monthly alarms described here: How to implement yearly and monthly repeating alarms? However I'm getting two errors on the lines: AlarmManager am = (AlarmManager) context .getSystemService(Context.ALARM_SERVICE); and PendingIntent sender = PendingIntent.getBroadcast(context, stating "context cannot be resolved" and "context cannot be resolved to a variable" ...any suggestions on how this can be resolved? public class Alarm extends Service { // compat to support older devices @Override public void onStart(Intent intent, int startId) { onStartCommand

change the intent of pendingintent which is used by an alarmmanager

我怕爱的太早我们不能终老 提交于 2019-12-02 08:36:50
问题 i have set some alarm like: public void SetAlarm(Context context, int tag, long time){ AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, Alarm.class); i.putExtra("position", tag); PendingIntent pi = PendingIntent.getBroadcast(context, tag, i, PendingIntent.FLAG_CANCEL_CURRENT); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+ time, pi); // Millisec * Second * Minute } now for some reason i want to update the Intent i of a

AlarmManager working well in emulator but not in real device

冷暖自知 提交于 2019-12-02 08:13:13
this is my code for setting alarm: public void SetAlarm(Context context, int tag, long time){ AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, Alarm.class); i.putExtra("position", tag); PendingIntent pi = PendingIntent.getBroadcast(context, tag, i, PendingIntent.FLAG_CANCEL_CURRENT); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+ time, pi); // Millisec * Second * Minute } this is my onRecieve methode: public void onReceive(final Context context, Intent intent){ PowerManager pm = (PowerManager) context.getSystemService

Run code every day at a specific time - AlarmManager

試著忘記壹切 提交于 2019-12-02 06:51:53
Currently, I am trying to run a piece of code at a specific time. After some research, I think the correct way to go is to make usage of the AlarmManger . The code should be executed every day at 3 am. If the phone is at 3 am shut down, the code should be executed directly after turning the phone on. I used googled and found a lot of results. But my code isn't working correctly. Yesterday I got a notification. The notification time was 10 pm. But in the code, the time is set to 3 am. I set up a lot of alarm manager over the time (because of testing). Could it be possible, that the triggered

to know next alarm time using setRepeating() method

拈花ヽ惹草 提交于 2019-12-02 05:13:59
问题 I have times like 9:00 AM, 1:00 PM, 7:00 PM, where I set 3 pending intents that are recursively triggered using setRepeating() method every day. (Here I am saving all these pending intents unique request codes in the local SQLite database) Here, whenever an alarm is triggered I would like to know the next alarm that is going to be triggered and show to user Example.. Now an alarm was triggered at 9:00 AM and at this time I should display the user that the next alarm is going to be triggered

i want to update my sqlite and firebase database every hour?

时光总嘲笑我的痴心妄想 提交于 2019-12-02 04:55:25
I want to update my local sqlite and firebase database every hour. But I can't use the broadcast receiver as it was ban in android o. I can't use Job scheduler and work manager as it is a timebase application. I don't want to foreground service because it will use lots of resources and required to show a notification that I can't show. 来源: https://stackoverflow.com/questions/57826280/i-want-to-update-my-sqlite-and-firebase-database-every-hour

Service pauses on screen lock

限于喜欢 提交于 2019-12-02 04:28:59
For testing purposes i have made a service that beeps every 1 minute. (No client-server interface yet). It beeps okay when the screen in on, but when it goes to sleep the beeping stops. I am making an application that has to periodically poll the a server for something. For this, I am trying to create a service that'll constantly be running in the background, poll the server every 1 min and then based on the reply from server it shall generate a task bar notification. I have a test activity with two buttons, 1 to start and the other to stop the service. And one service class named S_PS

sendWakefulWork not always called with cwac-wakeful-1.1.0

落爺英雄遲暮 提交于 2019-12-02 03:48:03
问题 I've got a problem for a long time now and I discovered cwac-wakeful, which could solve all my problems. I thought... :'( In short, for solving the problem, I've implemented a most simple app, which schedules alarm every 60 seconds and logs everytime. Here's my code : MainActivity : package com.par.hasard.mysimpleapplication; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends