Open Source • Background Tasks: Itoo 🚀

LogFile.txt (793.2 KB)

Here is the logcat file. I connected cable So In the TaifunBattery1_BatteryChanged block, I compared Status == Charging (replaced discharging)

Foe every block I placed Notifier START and END.

08-20 23:23:58.987 7031 7031 I Notifier: ui_procSBG
08-20 23:23:58.989 23637 31932 D AF::TrackHandle: OpPlayAudio: track:1374 usage:1 not muted
08-20 23:23:58.993 7031 7031 I ItooCreator: get: attempt p$ui_procSendBackground3 = true
08-20 23:23:58.993 7031 7031 I ItooCreator: get: returning p$ui_procSendBackground3

here ui_procSendBackground3 START - ui_procSendBackground3 END not executed. same as ProcessStopClock_Timer - START not executed.

As already said earlier

Rename the procedure and make sure to not use ui components for background processing

Taifun

Thanks. I removed ui component for background processing. and it did work for android 12/13 phones. But when I tried in Android 15 /16 devices. “app keeps stopping” pop up appears.

Logcat file attached here.

LogCat_Android15.txt (742.7 KB)

this is the relevant error

FATAL EXCEPTION: main
08-21 14:32:22.764 28087 28087 E AndroidRuntime: Process: appinventor.ai_downprash.batterychecker_6_Classic_BLE_V11_T1:doraemon, PID: 28087
08-21 14:32:22.764 28087 28087 E AndroidRuntime: java.lang.RuntimeException: Unable to start service xyz.kumaraswamy.itoo.ItooService@ace41da with Intent { cmp=appinventor.ai_downprash.batterychecker_6_Classic_BLE_V11_T1/xyz.kumaraswamy.itoo.ItooService }: android.app.InvalidForegroundServiceTypeException: Starting FGS with type none callerApp=ProcessRecord{14e338a 28087:appinventor.ai_downprash.batterychecker_6_Classic_BLE_V11_T1:doraemon/u0a624} targetSDK=35 has been prohibited

you have to choose the correct foreground service type for your purposes and create a custom extension as described here Open Source • Background Tasks: Itoo 🚀 - #1366 by Kumaraswamy

EDIT or use the template and just click Download to get your custom extension

Taifun

Hi,

I tried different custom extension, Background Bluetooth communication Connected device + BL permissions Itoo Manifest and other custom extension. But it works for android 12-13 but not for android 15-16 devices. I created simple blocks which I shared here. Issue remain same.

BLE_Android_16.aia (313.1 KB)

LogCat_Android12-13.txt (799.5 KB)

LogCatAndroid15-16.txt (782.5 KB)

You should choose one foreground service type (and not all of them as in the first screenshot)
This should be done for the custom extension and later also in the blocks (also in designer possible)

The second screenshot looks better...

yes, because foreground service types have been introduced later, therefore it works there

from the log

FATAL EXCEPTION: main
08-22 22:45:22.303 21072 21072 E AndroidRuntime: Process: appinventor.ai_downprash.BLE_Android_16:doraemon, PID: 21072
08-22 22:45:22.303 21072 21072 E AndroidRuntime: java.lang.RuntimeException: Unable to start service xyz.kumaraswamy.itoo.ItooService@3ef17df with Intent { cmp=appinventor.ai_downprash.BLE_Android_16/xyz.kumaraswamy.itoo.ItooService }: android.app.InvalidForegroundServiceTypeException: Starting FGS with type none

yes, you should choose a foreground service type. none will not work
use the custom extension from the template and set the foreground service type in the blocks to ConnectedDevice

Taifun

In this itoo template ForegroundServiceType block is not available.

In which template I can get this. Can you share the relevant template please.

Is it available in the designer ?

If not, then there is a bug in the extension and we have to wait for @Kumaraswamy

Either the extension is able to set the foreground service type automatically according to the generated custom extension or a property in designer and/or blocks should be available to set it

Taifun

No sir in the designer it is not available.

@Kumaraswamy Sir, Can you please look into it.

I think you should probably remove itoo first, and then test if BLE runs correctly under API level 36 before using itoo.

I tried that. Initially I implemented without using itoo. I did make sure that the BLE connect, disconnect and data share operation works fine for Android 12,13,15,16. then I added itoo. For background service. And it works for Android 12-13 but not for latest version Android 15-16.

Hello @downprash,

In your project, I see that you have properly included the Itoo extension with appropriate permissions and the correct service type (connectedDevice) as indicated by the screenshot you posted:

However, I have opened your given project file in the IDE and there's a tiny thing missing. You forgot to check the "ConnectedDeviceUsage" in the designer:

Which explains the crash you are witnessing on newer Android devices.


To clear the confusion regarding the ForegroundServiceType block, it was removed in the latest version of Itoo which introduced a better system to configure services. The documentation wasn't updated to reflect these changes.

BLE_Android_15_16.aia (314.0 KB)

Dear Sir,

In this file and screenshot I have selected ConnectedDeviceUsage. Still the issue remain the same.

Here's another testing suggestion: use only itoo+ble, and only select one ConnectedDevice in itoo, don't select multiple types, to simplify the problem.

That’s awesome. I selected only ConnectedDeviceUsage and it works perfectly now. Thank you, sir.

Kumar sir actually pointed this out in his post, but yesterday I selected multiple options in the designer. I assumed checking multiple options wouldn't be an issue, but it was actually causing the error.

Now I’ll analyse logcat file for any other issues.

@Kumaraswamy Sir and @Taifun Sir. Thank you for your valuable inputs.

1 Like

If multiple foreground services are required simultaneously, the foreground services need to be declared in advance when each service starts, and the default foreground service types need to be declared again after use. This is necessary to ensure the smooth use of multiple foreground services.

2 Likes

i want read sms and store data in mysql database. i do this already, when app in minimize its work, but when i cloose app from minimize its not work.

You could do this in the background with the help of the sms receiver extension

Taifun

Hi, does the extension work with the screen locked? I’ve already got it working with the app closed, and I also need it to work when the phone is on the lock screen, but I’m not sure if that’s possible.

Did you add some logic which works while your app is in the foreground?

Do you like to reveal, what exactly you are trying to do? This probably could help to answer your question...

What did you find out after doing some tests yourself? You could add debug statements using Notifier.LogInfo and check logcat

Taifun