Sharing component not working with deployed app but is working when connect to AI Companion

Hi all

Overview of the process
I've created application to be shared within small user group.
Application checks for a DeviceID (stored in TinyDB) and verifies if its registered for the said user.
This verification is against a google sheet that's managed by the app creator. Once a device is registered, the user is allocated a password for future logins. With each login thereafter, the application verifies DeviceID and the password that is paired with the ID.

Problem space
Now, if the the app does not detect a DeviceID when launched, then it asks the used to register the device. The process generates a code when the user selects the "Register" option from the ShowChooseDialog and thereafter fires the sharing component.

The component opens up a selection of apps to share the message (in this case the DeviceID that is randomly generated for the first time) with the app creator. However when I select any of the apps, it doesn't do anything. It's as if the component has been disabled or doesn't have permissions to execute. At face value it looks as though the original application is closed, but upon closer inspection its just lost focus and is still running in the background. When I select the app running in the background, it then restarts the process of asking me to register and then fires the sharing method all over again.

This bit of code has been operational now and working for well over a year, up until today when I added more functionality elsewhere (in an unrelated screen) and then recompiled. The perplexing this is that when I connect to AI Companion, it works as expected. I am able to select a sharing app to send the generated msg and actually send it. However, when I generate the .apk and install, it doesn't work at all (on my device at least). Strangely, the .apk works though on a few other android devices but not on mine.

Devices that do not work:
Samsung s10 - Android Version: 11 build number: RP1A.200720.012.G973FXXSBFUF3
Xiaomi MiNote 9 Pro - Android Version: 11 RKQ1.200826.002; MIUI Global 12.0.4 Stable

Devices that do work:
Samsung A30s - Android Version: 10 build number: QP1A.190711.020.A307FNXXU2BUD4
Samsung A50 - Android Version: 11 build number: RP1A,200720.012.A505FDDS9CUF2
Xiaomi MiNote 9 Pro - Android Version: 10 QKQ1.191215.002; MIUI Global 12.0.3 Stable

Any guidance would be greatly appreciated.
Thanking you in advance.


Here is a snippet of the code:
Navigate to the Sharing1 control marked with the red arrow.

First toubleshoot - I created a new sharing component and swapped out the original for the new one. This didn't solve the problem.
Remember - this bit a code is working well on some devices but not on others.

Second troubleshoot - I then decided create a new screen (screen3) and replace the Sharing1 method (where the red arrow is pointing) with a call to open the new screen.

The new screen has a single push button which when pressed, calls a new sharing method.
When the app is built and the new .apk installed, then the sharing method on this new screen works perfectly on the device that problematic to begin with. It gives the user a choice to select the app to share a message.

I'm stumped.

I've modified this piece of code and it's now working.
Moved the saving to TinyDB1 up one level and disabled the close application method.
Disabling the close application is of vital importance as the ShareMessage method just doesn't work if not.
It's almost as thought the process fires the ShareMessage but then runs through to CloseApplication before it has a chance to complete the ShareMessage process in full (i.e. selecting the app to share the message with).

Why would this be the case?

so the issue is closing the app while the sharing still is in progress...
unfortunately there is no event, which fires as soon as sharing is finished...
which app are you using to share the message?


Hi Taifun

I'm choosing WhatsApp.

What I don't understand though is why this is working okay on certain devices but not on others.
Very strange.