Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Fix: Alarm rings NOW in DateTime.now (in a difference of 1 sec) #68

Conversation

dtkdt100
Copy link
Contributor

@dtkdt100 dtkdt100 commented Jul 21, 2023

FIx (#66)

Before:

screen-20230721-104006.mp4

After

screen-20230721-104628.mp4

@gdelataillade
Copy link
Owner

Hi @dtkdt100,

Your added code will only run when the alarm is set to sound at the precise moment it is activated. Is this what you want ? What's the use case ?

@dtkdt100
Copy link
Contributor Author

@gdelataillade For me the use case is:
I am developing an app that do alarm by GPS and when the user will arrive at the right location I want the alarm to ring now.

Also, in your example app there is a button for "Ring now", so I tought if it is in your example app it must be used for something

@gdelataillade
Copy link
Owner

Hi @dtkdt100,

OK I see. The NOW button in the example is to show the proof-of-concept.

@gdelataillade
Copy link
Owner

Did you make some tests ? Your code works good ?

@dtkdt100
Copy link
Contributor Author

dtkdt100 commented Jul 21, 2023

@gdelataillade Yes.

Tests:

  1. Rings now (as you can see in the video)
  2. Set an alarm for one min later (works fine, alarm and notificaiton are working good)

@gdelataillade
Copy link
Owner

Does your GPS app has to ring even if the app is on background ?

@dtkdt100
Copy link
Contributor Author

Indeed.
I am using fullScreenIntent: true in FlutterLocalNotificaion and AudioSession in Android or VolumeController in iOS in oder to set the volume up as suggested in #37

@gdelataillade
Copy link
Owner

With the code you added, are you sure the alarm will ring in the background ? Because the point of using AndroidAlarmManager is to be able to run the Flutter code even if the app is on background.

@dtkdt100
Copy link
Contributor Author

Yes it is working for me. But i am not sure if it is because of fullScreenIntent: true.

But in this case there is not option that the phone will be in background because when you start the alarm the app will be in foreground, the alarm rings immediately

@gdelataillade
Copy link
Owner

OK cool, then give me a few days to run some tests and take a look at fullScreenIntent: true. I'll keep you updated. In the meantime you can use your fork for your project.

Thanks for your work.

@dtkdt100
Copy link
Contributor Author

Thanks for your quick response!

lib/src/android_alarm.dart Outdated Show resolved Hide resolved
@dtkdt100 dtkdt100 requested a review from gdelataillade October 2, 2023 14:10
@dtkdt100
Copy link
Contributor Author

dtkdt100 commented Oct 2, 2023

@gdelataillade
Ready to merge

Copy link
Owner

@gdelataillade gdelataillade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@gdelataillade gdelataillade merged commit 34afa06 into gdelataillade:main Oct 3, 2023
1 check passed
@gdelataillade
Copy link
Owner

Merged to main branch ! Thanks for your contribution !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants