• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Tasker based app restarts when killed

amankhalid

Newbie
Jul 5, 2014
30
2
Hi,

I have a few tasks that are exported as an app. The app uses a scene as well. While the app is running, if I use the Android multi task button to swipe the app out or use the “cross” button to close the app, the app relaunches after a few seconds.

My app has a main task which launches a sub task which performs tasks at 9am and 9pm and waits otherwise. Can someone shed some light on this behaviour?

My device is a running Android 7.1.

Regards,
AK
 
Sorry it took a while to get to reply to you.

Below is the main task that's started by the app:

Looper Starter (14)
A1: Display AutoRotate [ Set:Off ]
A2: If [ %TRUN !~ *,Looper,* ]
A3: Perform Task [ Name:Looper Priority:2 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ]
A4: Notify Sound [ Title:Main Run - Task Started Text: Icon:null Number:0 Sound File: Priority:3 Repeat Alert:Off ]
A5: Else
A6: Notify Sound [ Title:Main Run - Task Already Running Text: Icon:null Number:0 Sound File: Priority:3 Repeat Alert:Off ]
A7: End If
A8: Show Scene [ Name:popup2 Display As:Activity Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:Off Show Over Keyguard:On Continue Task Immediately:On ]
A9: Display AutoRotate [ Set:On ]


Below is the subtask started by the main app:

Looper (13)
A1: Variable Set [ Name:%interval_min To:1 Recurse Variables:Off Do Maths:Off Append:Off ]
A2: Variable Set [ Name:%wait_duration To:(60* %interval_min) - (%TIMES % (60 * %interval_min)) Recurse Variables:Off Do Maths:On Append:Off ]
A3: Notify Sound [ Title:I Am Waiting For %wait_duration Sec Text: Icon:null Number:0 Sound File: Priority:3 Repeat Alert:Off ]
A4: Wait [ MS:0 Seconds:%wait_duration Minutes:0 Hours:0 Days:0 ]
A5: Notify Sound [ Title:The Wait Is Over Text: Icon:null Number:0 Sound File: Priority:3 Repeat Alert:Off ]
A6: [X] Secure Settings [ Configuration:Screen & Keyboard Lights On
5 Seconds Timeout (Seconds):0 ]
A7: Notify [ Title:Trigger Text:%TIME Icon:null Number:0 Permanent:Off Priority:3 ]
A8: [X] Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]
A9: Goto [ Type:Action Number Number:1 Label: ]

Regards
AK
 
Upvote 0
Tasker tasks by default run in the background. The only reason anything appeared on the recent apps screen at all is because you have a Show Scene in your task.

The way to stop a task is with the Stop action.

It made into an app the following task will run forever and there will be an entry in the display.

If you comment out the Show Scene and make the app it will not appear in the display.

If you remove the comment on the Stop action it will run once.

Dev7 (556)
A1: Show Scene [ Name:tlaABC Display As:Activity, No Bar, No Status Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:Off Show Over Keyguard:Off Continue Task Immediately:On ]
<Start>
A2: Variable Set [ Name:%temp To:0 Recurse Variables:Off Do Maths:Off Append:Off ]
<Loop>
A3: Flash [ Text:%temp Long:On ]
A4: Variable Add [ Name:%temp Value:1 Wrap Around:0 ]
A5: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
A6: Goto [ Type:Action Label Number:3 Label:Loop ] If [ %temp < 5 ]
A7: Goto [ Type:Action Label Number:1 Label:Start ]
A8: [X] Stop [ With Error:Off Task: ]

For completeness, this the scene …

Scene: tlaABC
P:1024x256 L:1042x1072

Orientation: Sensor Portrait
Background Colour: #00000000
Action Bar Style: System
Title: Day And Night
Subtitle:
Icon: null
Tab Labels:

Element: Rectangle1/Rectangle
Geometry:
P:0,0 1024x256 L:0,0 880x976
Content:
Shader: None
Colour: #FF000020
End Colour:
Border Width: 2
Border Colour: #FFFFFF00
Corner Radius: 30
Rounded Corners: All
Events:
Click: 104

Element: Title/Text
Geometry:
P:0,0 1024x256 L:0,0 512x256
Content:
Text: tlaABC
Text Size: 18
Text Width Scale Percent: 100
Text Colour: #FFFFFFFF
Font:
Position: Centre
Vertical Fit Mode: None
Text Format: Plain Text
Events:
Click: 112

… Thom









tasker tasks by default run in the background.
 
Upvote 0
Hi,

Thanks for the example.

How do I get these in my Tasker to test?

BTW, I noticed that your example does not have two tasks.

So, I stopped launching the sub task from my main task and added the STOP action. I still have the scene being displayed and the problem is gone.

I need to have the sub task keep running in the background even when the scene is closed. I understand that running off a trigger is ideal. Would that solve the issue hopefully?

If the trigger is time, say 9am and there is no internet connectivity the sub tasks does HTTP get, I guess, it can spawn another task. Just thinking out loud....

Regards
AK
 
Upvote 0
You need to experiment with profiles and projects to see how it all fits together.

There are limitations in the Profiles. You cannot have an exit task in a profile if the trigger is time. It makes no logical sense.

You can have a task in one profile monitor if another task is running. This includes tasks in other profiles.

When building an app form a project you need to identify the initial task to be executed. So you need to tap on the app once to get it started.

It is also common to have a Boot profile that launches apps you want to always be running without having to first task on its icon.

So … the bottom line is … experimentation.

… Thom
 
  • Like
Reactions: Xavier Black
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones