alarmmanager

Android design : background long running service or AlarmManager?

假如想象 提交于 2019-12-28 18:19:19
问题 I am building an app which will monitor the battery state, wifi connection and location data at regular intervals and will write the results in a file (and later send them off to a server). On installing the app monitoring should be disabled - but the user enabling it should survive a reboot. After a lot of reading I have realized that I have basically 2 options : Subclass Service and fire it off from my activity. Set it on foreground, STICKY and what not and hope that it is not killed by

Android: AlarmManager is not getting fired

那年仲夏 提交于 2019-12-25 08:56:48
问题 I am trying to generate an alarm on a scheduled time in future. Below is the code MainActivity.java import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import android

Can i use Firebase JobDispatcher for triggering time specific tasks

瘦欲@ 提交于 2019-12-25 08:52:22
问题 I am developing an application where certain tasks as to be done in background at a specific time. Android developer docs suggests various methods. I know AlarmManager can be used for this purpose. But, I think, using AlarmManager in Android 6.0 in Doze mode will give improper triggers. I came across JobScheduling libraries from developer docs As my application supports version below Android 5.0. I thought of using FireBaseJobDispatcher. Can I use FirebaseJobDispatcher for trigger a specific

Android Start task within specific time

≡放荡痞女 提交于 2019-12-25 08:45:06
问题 I want my task to be started at 12, 3, 6, 9 pm on every day. To these hours, a method should be called. How can I implement such a scenario. If anyone can grant a resource or code example, it is admirable. 回答1: Check out the AlarmManager http://developer.android.com/reference/android/app/AlarmManager.html Search stack for examples, here is one Alarm Manager Example 来源: https://stackoverflow.com/questions/10700003/android-start-task-within-specific-time

Android: AlarmManager recuring tasks once a day at midnight

那年仲夏 提交于 2019-12-25 08:08:11
问题 I am trying to make a task repeat at the end of each day (23.59) to do so I would like to use alarmmanager.setRepeating(). In my test i have come up with a bit of code that i thought would repeat a task every second, it works but instead of being everyseconds it repeats the tasks every minute, I am not sure why and therefore I am not sure that I will be able to make it work for every day. Here is my code: public class RecurringTasks extends BroadcastReceiver { @Override public void onReceive

Android doze mode

被刻印的时光 ゝ 提交于 2019-12-25 07:27:34
问题 In My app I'll use an Alarm to notify user for event, the problem is on Android version 6.x- The alarm is delivered after same minutes of the exact times. This is only when the device enter on sleeping mode. I tried to wakelock the device before the alarm, but to no avail. Can anyone help me? this is my code Set the alarms if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, alarmCalendar.getTimeInMillis(), pendingIntent); if

Using AlarmManager to sync data with a server

与世无争的帅哥 提交于 2019-12-25 06:20:57
问题 First of all, I apologize for my English. I need to sent data to a server and query for data in that server from time to time, maybe from week to week. So I'm going to use the AlarmManager to do that. I wanna know if I can register two separated pending intents in the alarm manager, one to push data to the server, and another one to query data from the server. Can I register those two intents every time the application executes? Or do I need to test if I already got those intents registered?

Android - How to stop showing notification when open application

醉酒当歌 提交于 2019-12-24 19:23:12
问题 I'm new to android development... trying to build application which send notification at specific time daily.First time if I tap on notification it opens application and notification doesn't come again. But after that if I open application it shows notification again.. how to stop showing it again? but show only at particular time? .. MainAcitivty code is: public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate

getting method not found setTime(long) in AlarmManager when tried to set time and date in android system time

旧巷老猫 提交于 2019-12-24 18:13:09
问题 I'm trying to set the system time and date on an Android device. I thought the following code would work, but it produces the error method not found: setTime(long) Calendar c = Calendar.getInstance(); c.set(2010, 1, 1, 12, 00, 00); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.setTime(c.getTimeInMillis()); 回答1: It is not possible for an application to change the date or time on an (non-rooted) Android device. From the documentation for AlarmManager

How to cancel an AlarmManager

早过忘川 提交于 2019-12-24 16:16:21
问题 I have setup an alarmManager as follows: Intent intent = new Intent(TopActivity.this, RecordActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(Utils.KEY_RECORD_TIME, recordLength); intent.putExtra(Utils.KEY_REC_START_TIME, start); saveTimeAndLength(start, recordLength); PendingIntent pintent = PendingIntent.getActivity(TopActivity.this, 0, intent, 0); AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE); alarm.set(AlarmManager.RTC_WAKEUP,