Cebuvi Active Member Licensed User Longtime User Jan 23, 2023 #1 Hello, I have upgraded B4A to version 12.2 and found that the homescreen widgets now work with Receivers. I have studied the example in the post https://www.b4x.com/android/forum/threads/android-home-screen-widgets-tutorial-part-i.10166/#content and I understand that to update my app I have to follow the following steps: - create a Receiver Module. - include in it all the code that was in my old widget service keeping the structure of the new module. Is this correct? Thank you.
Hello, I have upgraded B4A to version 12.2 and found that the homescreen widgets now work with Receivers. I have studied the example in the post https://www.b4x.com/android/forum/threads/android-home-screen-widgets-tutorial-part-i.10166/#content and I understand that to update my app I have to follow the following steps: - create a Receiver Module. - include in it all the code that was in my old widget service keeping the structure of the new module. Is this correct? Thank you.
Cebuvi Active Member Licensed User Longtime User Jan 24, 2023 #3 The code in the old widget is in the Sub Service_Start and Sub Service_Destroy, where should I add it now? Last edited: Jan 24, 2023 Upvote 0
The code in the old widget is in the Sub Service_Start and Sub Service_Destroy, where should I add it now?
Erel B4X founder Staff member Licensed User Longtime User Jan 25, 2023 #4 Service_Start -> Receiver_Receive There is no equivalent "destroy" method. Upvote 0
Alessandro71 Well-Known Member Licensed User Longtime User Jan 25, 2023 #5 since we can't assume Starter is running, all global data that usually is declared in it, should also be ported to the Receiver module, I think. For example a SQLite database, should be opened, read and closed within the Receiver module? Upvote 0
since we can't assume Starter is running, all global data that usually is declared in it, should also be ported to the Receiver module, I think. For example a SQLite database, should be opened, read and closed within the Receiver module?
Erel B4X founder Staff member Licensed User Longtime User Jan 26, 2023 #6 True. It doesn't mean that you need to duplicate code. You can implement it in a class and make an instance in the receiver class and in one of the B4XPages. Upvote 0
True. It doesn't mean that you need to duplicate code. You can implement it in a class and make an instance in the receiver class and in one of the B4XPages.
Alessandro71 Well-Known Member Licensed User Longtime User Jan 26, 2023 #7 Erel said: True. It doesn't mean that you need to duplicate code. You can implement it in a class and make an instance in the receiver class and in one of the B4XPages. Click to expand... Since tapping the widget also opens the main app, there’s a chance that the widget will update while the app is in foreground. this means the database object will be instantiated 2 times and the database file opened 2 times: since it was stated that the Database object should be a global, single one to guarantee concurrency, this is giving me headaches… Upvote 0
Erel said: True. It doesn't mean that you need to duplicate code. You can implement it in a class and make an instance in the receiver class and in one of the B4XPages. Click to expand... Since tapping the widget also opens the main app, there’s a chance that the widget will update while the app is in foreground. this means the database object will be instantiated 2 times and the database file opened 2 times: since it was stated that the Database object should be a global, single one to guarantee concurrency, this is giving me headaches…
Erel B4X founder Staff member Licensed User Longtime User Jan 27, 2023 #8 Make it a process global variable and check whether it was already initialized or not. Upvote 0