Maintain the activity of an application in the background

Hello everyone

Sorry for my poor english.
I am using some extensions, TaifunTools, TaifunBattery and List Permission.
Is there a way to maintain the entire working of an application when it is in background and the only way to leave is to hit a button inside the app.
My apps use sensors ; GPS, accelerometers, gyroscope, clock, magnetometer in real time and makes lot of calculations driving display that must not stop or interrupt anyway.

Sincerelly

Hello,

for background tasks you need this extension:

you have several examples in the community relative to it.

Thank you Ramon

I dont need to run background task but the entire app, is this extension useful for that ?
I am not a professional english speaking developer and i dont understand everything explained, witch way to obtain what i need ?
I hope someone wil help me.

Sincerelly

Yes you can

Guidelines for using Itoo

  • First get your background functionality running in the foreground. Like this, you can find errors much easier. And as soon as you got it working in the foreground, then test it in the background.
  • Read the complete Itoo to leaarn how Itoo works and try the example projects, See also the battery checker tutorial and notification listener and itoo tutorial.
  • Do not use global variables while in the background, use local variables instead
  • Do not use any user-visible or UI components in the background
  • In the background, use the Itoo StoreProperty/FetchProperty methods rather than TinyDB. TinyDB relies on SharedPreferences which will not ensure data synchronization across background processes.

Taifun

Thank you Taifun

I use more of one hundred global variables and lists used in many calculations and i never used only one local variable, i have 3673 blocs and i cannot do like that, so it wont work ?

Sincerelly

It will work after redesigning your app and following the guidelines

Taifun

Ok, thanks

Hello

I try to understand how to use Itoo, please how to use process (foreground) or task (background) with accelerometer, gyroscope, GPS and clock using blocks like "acceleration changed" and "gyroscope changed" ?

Sincerelly

The first thing you should clarify is what you mean by “background”:

  1. The app has been closed. -> Itoo
  2. The app is in the background, is not visible or the device is in idle mode (screen off). -> Foreground service

use the foreground process for your purposes and follow my suggestions earlier

then show us a screenshot of what you tried so we can suggest...

Taifun

Hello

If i use foreground process or background task to launch gyroscope or accelerometer or GPS or clock, blocks like "acceleration changed" will work ?

When screen is locked or an other app is launched my app dont collect sensors informations and calculations are not done in real time, so when displaying again all is out of date.
It should be nice to alternate applications or lock screen to avoid batterie consumption and device heating.

Also using a tablet with Android before 10 with split screen only one off the two apps is active by clicking on it,
so my app doesnt need click after launched but using simultaneously a navigation app make it freeze, thats why using some tablets is not usefull, its a serious problem for users.

Sincerelly

You can take a look https://youtu.be/OTIqOJK4SFo

What's so difficult about clarifying this simple question?

1 or 2 ?

I never tried that event myself, this is something for you to try... the corresponding event handlers, which look like a procedure theoretically should work

It looks like it is now time for you to try something and if you got stuck, post a screenshot of your relevant blocks

Taifun

Hello

Yes it is.

Sincerelly

:question:

Hello Taifun

Thank you, you helped me with your extensions in the past, now i will try.

Sincerelly

I just discovered how quote post, well, sorry i dont really understand your questions but i have wrote an explanation of my problems.

Sincerelly

Hello

Is there something wrong because nothing happen when launching.

Sincerelly

some observations

  1. in procedure app you forgot the argument x, which is required there

  2. you can't use labels in the background, use a notification instead or use the text to speech component or use the notifier to log something you can read in logcat, Capturing Device Logs using adb logcat

  3. if you want to trigger the Clock1.Timer event in the background, then you have to register that event for background processing and use a background handler which looks like a procedure...,how to register events see for example here Battery checker reminding you to unplug when fully charged

Taifun

Thank you Taifun

What is this ? : argument x

Why "background" ?
i thought that "process" run in foreground

Sorry i dont understand anything, i think i'll let it down.

Sincerely