Android Question [solved] No Receiver alarm on some smartphones.

voxel

Active Member
Licensed User
Hi,
By setting up a Receiver to launch a periodic task (for example, for testing every 30 minutes).

With a :
- Samsung Galaxy A13 / Android 14: alarm OK every 30 minutes
- Xiaomi Redmi A3 / Android 15: alarm KO

I have the impression that the Receiver's behavior is erratic. Is this a restriction on Android 15?

Have you ever encountered this type of problem? (i use SDK 36)

Manifest:
AddManifestText(
<uses-sdk android:minSdkVersion="28" android:targetSdkVersion="36"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:usesCleartextTraffic, "true")
AddPermission(android.permission.POST_NOTIFICATIONS)
AddPermission(android.permission.RECEIVE_BOOT_COMPLETED)
AddReceiverText(ReceiverNotification, <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>)
'End of default text.
SetApplicationAttribute(android:theme, "@style/LightTheme")
CreateResource(values, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Material.Light">
       <item name="android:actionMenuTextAppearance">@style/LowerCaseMenu</item>
       <item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
       <item name="android:windowTranslucentNavigation">false</item>
       <item name="android:windowTranslucentStatus">true</item>
       <item name="android:forceDarkAllowed">false</item>
    </style>
     <style name="LowerCaseMenu" parent="android:TextAppearance.Material.Widget.ActionBar.Menu">
        <item name="android:textAllCaps">false</item>
    </style>
</resources>
)


ReceiverNotification:
Sub Process_Globals
   
   
End Sub

Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
   
    Log("Service démarré")
   
    'code download + display notification

    ScheduleNextDownload
   
End Sub

Sub ShowNotification(titre As String,detail As String)
   
    Log("Lancement notification")
   
    Dim n As Notification
    n.Initialize2(n.IMPORTANCE_HIGH)
    n.Icon = "icon_notif"
    n.AutoCancel = True
   
    n.SetInfo2(titre,detail,"",Main)
   
    n.Notify(1)
   
End Sub


Sub ScheduleNextDownload
   
    CancelScheduledService(Me)

    Log("Initialise StartReceiverAt")
   
    Dim target As Long = DateTime.Now + DateTime.TicksPerMinute * 30
    Log("Prochain téléchargement planifié pour : " & DateTime.Date(target) & "-" & DateTime.Time(target))
    StartReceiverAt(Me, target, True)
   
   
End Sub
 
Last edited:

voxel

Active Member
Licensed User
I changed to setting an alarm once a day at 12:00 PM, without using "exact time," and it works for both smartphones.
- With the Samsung, when I wake it up from sleep mode, the notification appears immediately.
- With the Xiaomi, when I wake it up from sleep mode, the notification appears after a few minutes.
Thanks.

ScheduleNextDownload:
Sub ScheduleNextDownload
 
    CancelScheduledService(ServiceNotification)

    Log("Initialise StartReceiverAt")
 
    Dim now As Long = DateTime.Now
    Dim today As String = DateTime.Date(now)
    Dim target As Long = DateTime.DateTimeParse(today, "12:00:00")
    If target < now Then target = target + DateTime.TicksPerDay
 
    StartReceiverAt(ReceiverNotification, target, False)
 
End Sub

Now, I have another problem: my Receiver starts a (quick) download, and since the smartphone is asleep, there's a connection failure :-( (the notification does indeed show a connection failure). Do you have any ideas on how to solve this problem?
Is there a way to "wake up" the smartphone to maintain the HTTP connection?
Do I need to launch the Receiver more often to have a chance of the smartphone not going to sleep?
Should I stop using a Receiver and use a Service?

I'm really wondering if I should use notifications with Firebase instead; it seems more reliable to me (and perhaps simpler when I port this feature to B4i).
 
Last edited:
Upvote 0

wes58

Active Member
Licensed User
Longtime User
Yes - you do. And it has nothing to do with the title of this thread. You should start a new thread.
After so many years people are still doing this! What are you? Are you a Forum Police? Are you a Forum Owner/Moderator?
If you don't have an answer to his problem why do you bother.
It is his thread and it relates to what he is trying to achieve and has problem with - i.e. receivers. He (and probably many other users) would like to have a response to the issues they have in one thread.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
After so many years people are still doing this!
Respect the forum guidelines you've never read? Yes, we do! This way, the forum is easier to read. Imagine a thread about receivers with 90 posts about them. Should someone read all of them to find their answer? Or it would be easier to find a post with a title like “Download resources from a receiver”?

But this is Erel's forum so you have to (try) to follow the rules.
 
Last edited:
Upvote 0
Top