We have an android application, We need to schedule the below tasks on weekly once.

Have to automatically log out from our application.
Then have to log in automatically.

I google it and found Automation Testing Framework - Android UI Automation Using Python Wrapper but I wish to run the above task by scheduling.
I am not an Android developer, Kindly assist me to accomplish this task.
In case of logout user after a perticular time, then you need to create a middle layer(like intercepter) while calling api through retrofit in mobile end.
A logic follow in middle layer and your backend:
you need to send specific error code your from backend after a perticular time.
At mobile end we check that code in middle layer if error code is match then call logout user api and at same time call login api.
If you want only logout and not want to login again then send another error code for that.
have to schedule UI task in Android: have to automatically log out from our application and login automatically