alarmmanager

date and time not working in Alarm Manager

假装没事ソ 提交于 2019-12-14 03:22:41
问题 I'm having trouble working with the AlarmManager . I want to run AlarmManager using Calendar at a specific time. But the calendar doesn't work and AlarmManager always runs regardless of the time taken from the calendar. AlarmManager mAlarmManger = (AlarmManager) Objects.requireNonNull(activity).getSystemService(view.getContext().ALARM_SERVICE); Intent intent = new Intent(activity, MyReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(activity, 0, intent, PendingIntent

Do I need to Use an AlarmManager and WakeLock to periodically use a LocationClient?

北慕城南 提交于 2019-12-14 02:31:03
问题 Posts from over a year ago suggest that it is necessary to use a WakeLock to reserve CPU to gather location information (CommonsWare in particular here Android Periodic GPS location updates with AlarmManager inside a Service). However I do not understand why I cannot simply call a Service every 28 minutes, connect the LocationClient, set a timer to wait 2 minutes, then get the most recent location, disconnect the client, and then stop the service. Because Commonsware and the user who forked

Android BroadcastReceiver on BOOT_COMPLETED does not start alarm

为君一笑 提交于 2019-12-13 14:09:52
问题 I'm trying to use a relatively simple solution to execute some code on boot. Basically I want to schedule/reschedule an Alarm at boot to execute a certain task in the future. In my manifest I have: <uses-permission android:name="com.android.alarm.permission.SET_ALARM"/> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <receiver android:name="com.cswt.lcyairport.alarm.AlarmReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> <

AlarmManager starting application instead of just sending notification

蓝咒 提交于 2019-12-13 12:22:27
问题 I currently have an app which, when a button is pressed, and after a certain period of time, a statusbar notification is set. Everything works fine apart from the fact if the user does not have the application open, when the notification appears, the app also reopens. This is not what i would like to happen. I would like the notification to appear on it's own (wherever the user is). On my button press i use: // get a Calendar object with current time Calendar cal = Calendar.getInstance(); //

Android notification start when ever I open app

本小妞迷上赌 提交于 2019-12-13 07:23:20
问题 I am adding notification to my app, Everyting is working fine if app is shut down, and it fires notification exactly as i want, but when ever i start app, and on create is called notification fires. If i leave app and start app again, notification will fire again. However, when ever i open my app notification fires. I do not want that behavior. This is a code for for notifications and i put code in onCreate : I know that i should move this from onCreate but where to move it? Is it possible to

Android Alarm Manager and BroadcastReceiver

狂风中的少年 提交于 2019-12-13 06:36:33
问题 Im trying to set an alarm that will send an intent to a broadcast receiver. The reciever should then print a line in the logcat stating it has worked. However I'm getting no indication that the reciever is receiving anything. I've checked all the things I can think of. Can someone give me some guidance as I am at a loss? Alarm Method public void scheduleNextUpdate() { Intent intent = new Intent(MainActivity.this,AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast

How to popup Alarm Message without any activity in background?

痞子三分冷 提交于 2019-12-13 06:32:20
问题 In my android i app i can alarm functionality and as well logout functionality. After setting my alarm time i am exiting the app by clicking the logout button. I am using ExitActivity.this.finish(); Intent intent1 = new Intent(ExitActivity.this,PinActivity.class); intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent1); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity

Android loop service every 5 seconds and boot on startup

情到浓时终转凉″ 提交于 2019-12-13 06:16:25
问题 I have the code below and I want to loop this every 5 seconds. I have tried to use broadcastreceiver and alarm manager but without success . I want my service to loop for 5 times and after that stop permanently .This is the second question I post . Please somebody help me to fix the code, I am stacked on my mac for 2 days. Any help will be appreciated. Code to loop every 5 seconds File key = new File(Environment.getExternalStorageDirectory(),"newfile"+Math.random()+".txt"); try { key

Alarm Manager broadcasts unexpectedly

女生的网名这么多〃 提交于 2019-12-13 05:36:10
问题 I have a application which should fire up an alarm at a specified time stored in the database. The time is stored like (HH:mm) format, 24-hour format. Here is the code. SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); String temp = h+":"+m; Date date = sdf.parse(temp); alarmMgr = (AlarmManager)_c.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(_c, AlarmBroadcastReciever.class); alarmIntent = PendingIntent.getBroadcast(_c, requestCode, intent, 0); alarmMgr.set

Send notification id to receiver while set alarm

断了今生、忘了曾经 提交于 2019-12-13 05:33:05
问题 I try to set an alarm depending user chocies while setting alarm i want to send that alarm's unique notification id to reciever.java. I want to get data by this id on reciever.java. I have a form with this form users are adding their pills and I'm saving every pill in different xml files for example pill1.xml pill2.xml. That saved pills have alarm and notification when alarm time came for example pill2.xml i will show pill2 datas in notirifacation bar. that code on bottom is how i create