Android Question CallSubDelayed and Widgets.

NJDude

Expert
Licensed User
Longtime User
The attached sample is supposed to call a sub in the Main activity from a widget, however, nothing happens when I click on the button.

I tried on several devices and several Android versions, same problem.

Other things like StartActivity work just fine, but CallSubDelayed doesn't, not sure if I'm missing something or something needs to be fixed.

I'm running Android 4.3, B4A 2.71 and Java SDK 7 update 25.

NOTE: If you comment/remove the 'Activity.Finish' line in the code, the sub will trigger, but ONLY when you open the app and not from the widget.
 

Attachments

  • WidgetSample.zip
    11 KB · Views: 175
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
CallSubDelayed is actually used many times from services. See HttpUtils2 code for example.

This is how it works:
- You have sent a http request from your activity.
- The user then left your app.
- 10 seconds later the response is ready.
- If your app is in the foreground then the activity will be started and JobDone will be called.
- Otherwise the message will wait for the user to return to the app.
- When the user returns (assuming that the process was not killed) JobDone will be raised.
 
Upvote 0
Top