Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting Android App launcher activity based on user selection
    text
    copied!<p>I saw this same question asked before but the suggestion is exactly what I was trying from the beginning but its not working! I am trying to set the launcher activity of an android app. Based on the user selection the first time the app is launched after fresh install, the user gets a first time Activity screen, and based on his/her selection on that screen, from that point on the app will load the selected Activity on launch. And no matter what, the app keeps launching the first conditional activity(userselect activity). Here's what I tried(see code below):</p> <ol> <li>Use <code>setContentView(R.layout.myactivity)</code> based on the condition. So if condition 1, the view is this, otherwise that. This was done in the MainActivity class.</li> <li>Very similar to above solution, I created a empty class, and based on the condition, setup an intent for the respective class and then launch it followed by finishing this blank/empty activity. And ofcourse, this activity is the LAUNCHER activity in the manifest.</li> </ol> <p>Below is the code I have right now:</p> <p>A public class with conditional variable:</p> <pre><code>public class AppFirst_time { public static boolean instructorApp; public static boolean studentApp; public static void setInstructor(boolean instructor) {instructorApp = instructor;} public static void setStudent(boolean student) {studentApp = student;} } </code></pre> <p>Main Activity class:</p> <pre><code>public class Main extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = new Intent(); if(AppFirst_time.instructorApp == true) intent.setClass(this,InstructorMain.class); else if(AppFirst_time.studentApp == true) intent.setClass(this, StudentMain.class); else intent.setClass(this,UserSelect.class); startActivity(intent); finish(); } } } </code></pre> <p>Also would like to add, in the StudentMain.java and InstructorMain.java classes, I set the respective booleans to true:</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload