I just remembered, that I already was looking into this...
Taifun
I just remembered, that I already was looking into this...
Taifun
Yea sure!
Well fair enough , but in this case I'm pretty sure the foreground service still runs while I have the app open, so the event should trigger, and show the UI popup in app, and as for outside the app, I wouldn't really need something like a log since if the event does get triggered(which is during a phoneCall), the CallAccept method/function would be triggered, and it would accept the call, and I'd know that yes indeed the event got triggered, the notifier is just a little extra tid bit of info that might serve itself
So what are the conclusion of your tests? Where does it work or not work?
Well, to simply conclude, I just wasn't able to get the registerEvent to work with the phoneCall1.PhoneCallStarted event, everything else works fine, I did try it with the clock1.Trigger event as i said earlier, and things did work perfectly fine there.
Read again Detect that there is a call - #13 by Taifun - Discuss - Kodular Community why it does not work and what could be done to get it running
Taifun
Omg, I can't believe I missed this part of the thread , thanks a lot I'll make sure to read through it!
Yes indeed!!
I was able to solve my problem of needing immediate UI feedback from the Player component when running in the background by simply moving that code from the UI to the background . So now the main "show" runs in the background service and the UI executes control via Itoo.CallBackgroundProcedure and the background process updates the UI via the implicit ui_xxxxx mechanism.
No need for any locks or while loops!
However I have encountered a problem when attempting to report a Screen1.ErrorOccurred event when it occurs in the background process. The procedure Screen1_ErrorOccurred is not called. From what I can see in logcat output, it looks like the procedure "null_ErrorOccurred" is being sought and, of course, not found. When I add the procedure null_ErrorOccurred to the project, it DOES get invoked...
Here is a test case made from ItooMusic. The error that is induced (when the KDFC URL is toggled so that it is in error) is "702" and is caught and reported by both the UI and background players. However, if null_ErrorOccurred is disabled/removed from the project, the background player does not report the error.
I have attached the test project as well as some logcat output and screen shots. Let me know if I have not sufficiently explained this.
The test case:
ItooMusic_440_null.aia (4.2 MB)
The blocks:
Both players can be started by the UI and will play the KDFC San Francisco, CA, public radio stream using a URL.
When "Toggle KDFC URL" is clicked the URL is intentionally corrupted and neither player works. They report the error 702 in the label between the two sets of controls.
UI Error:
Background Error:
HOWEVER, If the project is modified to disable/delete procedure null_ErrorOccurred, the UI player reports the error 702, but the background service does not.
Here is some logcat output showing what is happening - null_ErrorOcurred is not found:
null-notFound.txt (1.8 KB)
12-26 23:30:37.450 9034 9034 E Form : Form null ErrorOccurred, errorNumber = 702, componentType = Player, functionName = Source, messages = Unable to prepare https://18323.live.streamtheworld.com:443/KDFCFM_S.
12-26 23:30:37.478 9034 9034 I ItooCreator: AEvent(ErrorOccurred=null) args [com.google.appinventor.components.runtime.Player@44804e8, Source, 702, Unable to prepare https://18323.live.streamtheworld.com:443/KDFCFM_S.] listener = xyz.kumaraswamy.itoo.Itoo$1@1dc8539
12-26 23:30:37.478 9034 9034 I ItooCreator: startProcedureInvoke: null_ErrorOccurred & -1
12-26 23:30:37.478 9034 9034 I ItooCreator: startProcedureInvoke: failed to find name(null_ErrorOccurred)
BTW, if "Toggle KDFC URL" is clicked again, the URL is repaired and both players work once again - no errors.
I need this functionality because the radio stream URLs I have used sometimes change - what works today my not work tomorrow
For now, I can use the null_ErrorOccurred workaround... but I figured it would be something that could be fixed(?) in a future release...and, as always, I may not be understanding this correctly.
Does this make sense?
Kind regards,
Randal
Hello Randal Andress, thank you for the error report, this is indeed a bug that needs to be addressed. I've noted it down and will be fixed in the new update.
No problem... workaround is easy. But I also am coding the event Player1_PlayerError. Is it likely to have a similar issue or is this just a Screen1 event issue?
-Randal
It is just a Screen1 event issue, since there's no actual Screen in background, the extension thus fails.
Thanks,
Randal
Hey,
Question about the SaveProcessForBoot method
When called it would set the desired procedure to run each time the phone restarts or starts up, but after calling, would there be a way to negate the call? Stopping it from running at start up? And also would it continue running at start up until cache or data of the app is cleared by the user?
Currently not
It always will continue running at start up no matter of any clearings of cache or data
Taifun
Alright that's good to know, thanks a lot for informing me!
Hello all, I have two requests about this extension:
@Kumaraswamy: Is it possible to improve the extension and get rid of the usage limitation of the global variables? I would like to use the extension in my project including several global variables that is difficult to refactor, because I need to bring around some of them in different spots of my app to trace the status of the app and to drive its execution logic, so these variables are supposed to be visible everywhere.
Is it possible to modify the message displayed in the permanent notification? I would like to exploit the notification to show a message that changes according to the status of my app.
Thanks in advance.
I would like to use the extension in my project including several global variables
Where exactly is the problem to use the StoreProperty/FetchProperty feature?
Example use Battery checker reminding you to unplug when fully charged
Taifun
Hello Taifun,
Thank you for your quick reply, your suggestion sounds very interesting and, I guess, the only feasible solution.
Here below the blocks of my app:
I believe it is worthwhile to explain a bit more of the history of my app.
The app was originally written to work in background mode by App Inventor Services. It worked like a charm, then App Inventor Services has been eventually shut down (App Inventor Services: this "services" service is obsolete - #5 by Salvatore_Oliva). However, I still have both aia project and apk files of my original app. Now I am in need to put my hands on the app to make it work on Android 15 (apk file is prevented from installing), but unfortunately I am no longer able to look at the blocks of my original app. I somehow succeeded in recreating and making the app run in foreground, now I would like to convert it to run in background by Itoo extension.
As you can figure, the modification involving global variables refactoring turns out to be quite heavy, since there are a lot of information getting around by them. On the other hand, as long as I acknowledge Itoo extension a very powerful and valuable project, caveat on global variables usage comes as a severe limitation.
I wonder if Kumaraswamy plans to modify and improve the extension in this sense. In the meanwhile, I will try to figure out how to modify my app as per your suggestion (it will be a lot of work!...).
Thank you again.
Use local variables where possible and use the StoreProperty/FetchProperty feature where not possible
And remember, in rhe background do not exist user interface components like labels and notifiers, use a notification instead
Melon Notification A rich library of various notification styles along with the combined power of Itoo Documentation Image resource Any image resource provided to this extension may be a full file path an asset name an URL starting with prefix url: an icon from the default Android Drawable collections it must start with the : prefix, for e.g. :ic_media_play only resources starting with ic_ are supported. If you intend to your custom icon, then please ensure the image is atleas…
Taifun
I wonder if Kumaraswamy plans to modify and improve the extension in this sense. In the meanwhile, I will try to figure out how to modify my app as per your suggestion (it will be a lot of work!...).
Thank you again.
Hi, I tell you to not use Global variables since its introduces another dimension of complexity to the application, which is often confusing and hard to debug for the users (and not worth the time). That's why we use Itoo's persistent storage method of Store/Fetch property.
In future, definitely improvements will be made in that direction, that's some time to wait.
Is it possible to modify the message displayed in the permanent notification? I would like to exploit the notification to show a message that changes according to the status of my app.
Yes, you can use melon notification to post a new notification to the Id (123321
) from the background procedure.
Alright, that's good to know, thanks everybody a lot for the help!