Android Question StartActivityAsync()

DT1111

Member
Licensed User
Longtime User
Hi Erel et. al.

Thanks Erel for introducing MsgBoxAsync as it is extremely useful in my case as the msgbox in now non-modal. Is it possible in Android to turn StartActivity() into StartActivityAsync()?

This is useful in the case when a timer is running in the main form and user calls another form via StartActivity which results in the counting in the main form stops. My guess is if "StartActivityAsync" is possible, then in that scenario the counting in the main will not be impeded.

Unless there is already a novel way to circumvent which I am not aware.

Many thanks.
 

DonManfred

Expert
Licensed User
Longtime User
It is not possible.
Move your counter to a service.
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Thanks Manfred and that was what I thought too ie moving code to a service.

I put any non UI related functions to services. If you need to display something just use f.e.

B4X:
CallSubDelayed2(ActivityName,"MySub",Value)

to call a sub in the Activity you need to. So the timer is inside the service. If it "ticks" just call a sub in the Activity you want to display something.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm not exactly sure what you are looking for. As KMatle CallSubDelayed can be useful here. Tutorial: Using CallSubDelayed to interact between activities and services

StartActivity is an async method. It sends a message to the internal message queue. The activity is started when the message is processed.

B4X:
StartActivity(Activity2)
Log("This message will be printed before Activity2 is started")
 
Upvote 0

DT1111

Member
Licensed User
Longtime User
Thanks KMatle. I have adopted that approach. I am just curious if it is ever possible to achieve what I am after if the codes stay in the main form.

Hi Erel I have put together a simple example to demonstrate what I am looking for. I hope it helps.
 

Attachments

  • StartActivity Example.zip
    9.4 KB · Views: 152
  • StartActivity.apk
    123 KB · Views: 140
Upvote 0

DT1111

Member
Licensed User
Longtime User
Hi

The example is to demonstrate the blocking effect of each called item on the functionality on the main timer and not so much of trying to put "counter's value inside the Label1.text of each activity".

I was asking if StartActivityAsync is possible so that an activity is not paused when form2 is called - just like MsgboxAsync.
 
Upvote 0
Top