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

Control screen orientation using Tasker

Hi,

I have the 7 eleven fuel app installed on my Android phone. A link to the app is below.

This app always runs in portrait mode. However, when I check the device rotation settings by pulling the notification shade down, it’s always set to auto rotation.

Using Tasker, I have a few tasks that use a scene that works in portrait mode only. I export the tasks as an app to use on other devices. In one of my tasks, I turn auto rotation off which forces portrait mode. When the app is closed, it turns auto rotation back to on. This happens when the “back” button is pressed. There are two cases which I don’t know how to handle because it leaves the portrait mode ON.

1. If user presses the home key to move away from the app
2. If user uses the multi task button to switch to another app

How do I handle this?

https://play.google.com/store/apps/details?id=au.com.fuel7eleven

Regards
AK
 
It would help if you posted the Tasker commands you are using in the task(?) in question.

Highlight Task
Select three dots
Select Export
Select Description To Clipboard
Paste into a message

... Thom
 
Sorry it took a while to get to reply to you.

Below is the main task that's started by the app. It has a auto rotate off and then on. If the scene is not set to auto continue, the back button dismisses it and the auto rotation is changed back to ON. If home or multitask buttons are pressed, then the app is still running (scene being displayed) and auto rotation stays OFF.

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: ]
 
Screen rotation is controlled by the app that is running.

A typical solution to your requirement would be to run as a profile and the Exit task would set rotation to the way you wanted it when leaving.

… Thom
 
Hi,

My task displays a scene. Would the exit task be executed when “back” button is pressed (while the scene is displayed)?

Does your proposed solution also handle if the “homeless and “multitask” keys are pressed?

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

I know of no way to monitor if the entry in the scene is present in the previous apps display or not. You can monitor if a task is running.

It is made more complicated because you want to make them into apps. To make a Profile and its Tasks and its Scenes’ into an app you need to create a Project, move the elements into the project, and then export the Project as an app.

So … the bottom line is … experimentation.

… Thom
 
Why don't you try to instead of adding an exit task..just create two profiles..one with the list of apps you want in portrait mode or view..then the second one with the ones you want in landscape..well, home is always gonna be in portrait mode any way..I hope that helps..

To Thom: I admire your knowledge in Tasker.
Also how to deal or create an exit task when isn't available but really needed??
 
You can use Task Running as a trigger to monitor another task. These can be Entry and Exit tasks in other Profiles.

You can set a global variable to mark a condition and test it in other tasks and profiles.

… Thom
 
You could create two profiles one with the trigger and the other with the Invert of the trigger.

The Enter task of the first would be the logical Enter task.

The Enter task of the second would be the logical Exit task.

… Thom
 
Thank you Thom..even thought I can't begin to understand what variable is..I've watched a lot of YouTube, read about it..and nothing..that's the only part of tasker I can't figured out..the rest is already logical for me..so far I've created a few profiles just by logic, imagination, analyzing, planning and like you always say: "experimentation"..that's the main ingredient I do believe so..

Like one for example that it's out there but supposedly the only way was by buying and installing the "syncer" plugin..well I did accomplish yesterday the same exact results without the syncer plugin..this profile is to keep the Sync on the phone off when ever isn't needed so you can save a lot of battery (here it is shared for those who want to benefit from it)..you can combine this one with the profile of the GPS to be off most of the times as well..it's really amazing what you can accomplish with this Tasker app!!!

Down below are the steps I took(exhibits 1, 2, 3 & 4)
 

Attachments

  • 2018-05-21 02.00.32.jpg
    2018-05-21 02.00.32.jpg
    280.1 KB · Views: 614
  • 2018-05-21 02.02.09.jpg
    2018-05-21 02.02.09.jpg
    312.3 KB · Views: 570
  • 2018-05-21 02.05.56.jpg
    2018-05-21 02.05.56.jpg
    267.4 KB · Views: 245
  • 2018-05-21 02.04.47.jpg
    2018-05-21 02.04.47.jpg
    226.1 KB · Views: 293
Last edited:
Two flavors of variables …
Global - has a capital letter in name - available to all profiles and tasks
Local - all lower case name - only available in task where it is defined

Try the following tasks. Run DemoA first and both are displayed. Run DemoB next and only Global is displayed.

DemoA
A1: Variable Set [ Name:%Global To:Global Set Recurse Variables:Off Do Maths:Off Append:Off ]
A2: Variable Set [ Name:%local To:Local Set Recurse Variables:Off Do Maths:Off Append:Off ]
A3: Flash [ Text:Constant - %local - %Global Long:On ]

DemoB
A1: Flash [ Text:Constant - %local - %Global Long:On ]

… Thom
 
Last edited:
Back
Top Bottom