giorgosneokleous93 / fullscreenintentexample

Full-Screen Intent Notification Android Example
MIT License
59 stars 26 forks source link

App can not wake device #7

Open DavidJH2 opened 3 years ago

DavidJH2 commented 3 years ago

Thanks for this VERY helpful example!

The issue is that the app can not wake the device since it is missing the wake lock permission:

<uses-permission android:name="android.permission.WAKE_LOCK" />

By adding this permission the app would be able to wake the device as well. As it stands it does not open in sleep-mode.

giorgosneokleous93 commented 3 years ago

@DavidJH2 thank you for the comment. I haven't checked the project for awhile, feel free to open an PR to have a working sample for people.

DavidJH2 commented 3 years ago

I just realized it does wake on the first run. Here are the steps to reproduce the issue:

  1. Run app
  2. Press 3rd button (Scheduled Full Screen Intent for Lock Screen)
  3. Put Device into Sleep-mode
  4. Wait for Full-screen Notification
  5. Hit Back Button
  6. Unlock Device
  7. Press 3rd button (Scheduled Full Screen Intent for Lock Screen) Again
  8. Put Device into Sleep-mode Again

May be the same as or similar to issue #6

DavidJH2 commented 3 years ago

On a retest I discovered that the Wake-lock permission does not fix the issue...

flauschtrud commented 2 years ago

@DavidJH2 did you find a solution? I'm currently also trying out this sample and have the same problem...

(Edit: I also checked out the solution by @sf99 from https://github.com/giorgosneokleous93/fullscreenintentexample/issues/5 regarding unique notification ids, but this does not seem to help)

sf99 commented 2 years ago

Hi, I did not find a solution. For some devices this does not work. It looks like Google will not support this.

Fabian

On Wed, Jan 19, 2022 at 2:04 PM flauschtrud @.***> wrote:

@DavidJH2 https://github.com/DavidJH2 did you find a solution? I'm currently also trying out this sample and have the same problem...

(Edit: I also checked out the solution by @sf99 https://github.com/sf99 from #5 https://github.com/giorgosneokleous93/fullscreenintentexample/issues/5 regarding unique notification ids, but this does not seem to help)

— Reply to this email directly, view it on GitHub https://github.com/giorgosneokleous93/fullscreenintentexample/issues/7#issuecomment-1016343987, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVUM4Y2SVU6NWMNJCEMK5LUW2ZHXANCNFSM445WZYVQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.*** com>

flauschtrud commented 2 years ago

Apparently I messed up yesterday when trying out the unique notification ids, so your solution seems to work for me after all, @sf99! (at least on a Pixel 2 emulator, I did not test anything else)

I changed notify(0, notification) to notify(Random.nextInt(), notification) in Utils.kt and now the device wakes up every time.

sf99 commented 2 years ago

Thank ou for information. The problem is with real devices. If you need to be 100,00 percent sure, that your alarm start, this is not the good solution. I do not know why, but some devices, sometimes does not start alarm, so I will not trust it. If you need alarm for 99,9 percent of situation, it may be OK. The most time, when alarm do not start is when the device is in sleeping mode. I had too many crash logs with this from Google analytics.

Fabian

On Thu, Jan 20, 2022 at 11:22 AM flauschtrud @.***> wrote:

Apparently I messed up yesterday when trying out the unique notification ids, so your solution seems to work for me after all, @sf99 https://github.com/sf99! (at least on a Pixel 2 emulator, I did not test anything else)

I changed notify(0, notification) to notify(Random.nextInt(), notification) in Utils.kt and now the device wakes up every time.

— Reply to this email directly, view it on GitHub https://github.com/giorgosneokleous93/fullscreenintentexample/issues/7#issuecomment-1017324564, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVUM43ZBAXGID2WZY7DVCDUW7O5DANCNFSM445WZYVQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.*** com>

duhovny commented 1 year ago

In case if anyone is looking at the same issue, for me the issue was in the NotificationReceiver class, when build function puts LOCK_SCREEN_KEY as true here:

it.putExtra(LOCK_SCREEN_KEY, isLockScreen)

then onReceive function for some reason cannot read/parse it properly here:

if(intent.getBooleanExtra(LOCK_SCREEN_KEY, true)) {
        context.showNotificationWithFullScreenIntent(true)
    } else {
        context.showNotificationWithFullScreenIntent()
    }

and ends up calling showNotificationWithFullScreenIntent() without isLockScreen: true.

Modifying this code and calling showNotificationWithFullScreenIntent(true) brings the LockScreenActivity fullscreen for me when the screen is locked.