Android Question Android SDK 34 and BOOT_COMPLETED start app

vasper

Member
Licensed User
Longtime User
As you can see in this screenshot, I have a Receiver that seems to work. However I cannot get the Main activity to start with either just calling StartActivity(Main) or StartActivity(intent) in this context.

I am running on Android SDK 34 and latest Emulator image.

Is there something I am not doing?

Receiver:
Sub Process_Globals
    Dim Timer1 As Timer
End Sub

'Called when an intent is received.
'Do not assume that anything else, including the starter service, has run before this method.
Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
    Log("Step 1")
    Timer1.Initialize("Timer1",5000)
    Timer1.Enabled=True
End Sub


Sub Timer1_Tick
    Log("Step 2")
    Timer1.Enabled=False
   
    ToastMessageShow("eCongress Kiosk Receiver",True)
    Log("Step 3")
    'Dim intent As Intent
    'intent.Initialize("android.intent.action.MAIN", "")
    'intent.SetComponent("com.econgress.kiosk/.main") ' Adjust if needed
    StartActivity(Main)
    Log("Step 4")
   
   

End Sub


Manifest:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="20" android:targetSdkVersion="34"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
AddPermission(android.permission.ACCESS_WIFI_STATE)
AddPermission(android.permission.CHANGE_WIFI_STATE)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
SetApplicationAttribute(android:usesCleartextTraffic, "true")
AddPermission(android.permission.RECEIVE_BOOT_COMPLETED)
AddReceiverText(Receiver,
<intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>)



Screenshot 2025-04-27 183824.jpg
 
Last edited:

drgottjr

Expert
Licensed User
Longtime User
at the very least, you are missing the AddPermission(android.permission.SYSTEM_ALERT_WINDOW) in your manifext, also you only need StartActivity(Main). and - most importantly - please don't ever post a picture of code again. use the "<code></code>" tags or upload the project. if someone wanted to run your code to test it, they would have to type everything by hand. thank you.
 
Last edited:
Upvote 1

vasper

Member
Licensed User
Longtime User
at the very least, you are missing the AddPermission(android.permission.SYSTEM_ALERT_WINDOW) in your manifext, also you only need StartActivity(Main). and - most importantly - please don't ever post a picture of code again. use the "<code></code>" tags or upload the project. if someone wanted to run your code to test it, they would have to type everything by hand. thank you.
I have updated with the code. Will do so from now on. Thanks.
 
Upvote 0
Top