Android Question Issue with startactivity

Sergio83

Member
Licensed User
Longtime User
Hello everybody,

I'm facing a very simple problem, I 'm shure I'm mistaken somewhere but where ?

I wrote an app with the "startatboot" option turn in the my Starter service, I try to activate the Main activity from it and the result seems to be a bit corrupted ...

So I wrote an app as most simple as it can be to test this feature and I got the same corrupted result.

Here after is the Main activity content:

B4X:
#Region  Project Attributes
   #ApplicationLabel: activity_start
   #VersionCode: 1
   #VersionName:
   'SupportedOrientations possible values: unspecified, landscape or portrait.
   #SupportedOrientations: unspecified
   #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
   #FullScreen: False
   #IncludeTitle: True
#End Region

Sub Process_Globals
   
End Sub

Sub Globals
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("main")
ToastMessageShow("activity create",False)
End Sub

Sub Activity_Resume
ToastMessageShow("Main activity resume",False)
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Here after is the Starter service content:

B4X:
#Region  Service Attributes
   #StartAtBoot: true
   #ExcludeFromLibrary: True
#End Region

Sub Process_Globals
   
End Sub

Sub Service_Create
   
End Sub

Sub Service_Start (StartingIntent As Intent)
StartActivity(Main)
ToastMessageShow("main activy starting",False)
End Sub

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
   Return True
End Sub

Sub Service_Destroy

End Sub

As you can see it's very simple but it does not work properly.

When I start manually the app I get the 3 toastmessages and the correct app GUI, but when I reboot my device (a TV Android box) the service starts well: I get only the first toastmessage: "main activy starting" but my GUI app appears empty and I get no more toastmessage.

Sorry to bother you for a so simple issue, but I've googled and step across the forum a lot with no result to fix this issue

It will be great of you if you could help me!

Regards
 

DonManfred

Expert
Licensed User
Longtime User
I wrote an app with the "startatboot" option turn in the my Starter service,
THIS is the problem. Dont use startatboot on the starter service. Use another service and set this service to startatboot
 
Upvote 0

Sergio83

Member
Licensed User
Longtime User
THIS is the problem. Dont use startatboot on the starter service. Use another service and set this service to startatboot
Hello DonManfred,

I done what you said and it works perfect.

I kill (stopservice) the new service from the main activity to avoid having a dummy service running!

Thanks a lot for your help !!!

Regards
 
Upvote 0
Top