Kotlin - change launcher activity based on a variable | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Kotlin - change launcher activity based on a variable

Dear Community I have 2 activities with some fragments. One activity should be an App setup activity, which should launch, only when the user opens the app the first time. He/she enters the username (...) and the MainActivity is launched now every time the app starts. In the MainActivity.kt file I have a variable and in the manifest file, the MainActivity is the launcher activity. Now, how can I change the "launcher activity" if the variable in the MainActivity.kt file changes? Thank you for your help.

16th Apr 2022, 1:40 PM
Julius
1 Answer
0
You have to create one more activity make that activity to default . Now take data from that variable if value is present to Mainactivity.kt then intent there if not present then intent to another activity. And also you have to save that variable so that everytime you open your app the launcher activity decides where to immediately intent on basis of empty or any string.
22nd May 2022, 11:00 AM
Anubhav A
Anubhav A - avatar