Change Android Default Launch Setting when User Presses an Item in a List -


Let's say we have a screen A. When the application is first loaded, the user is taken to A screen. Screen A has a list of items which are moved to screen B, C, D or E. When users press one of these items, they are directed to whatever screen is selected. Then when the user closes the app or closes their phone and reloads the app, they are taken to the screen, instead of the screen A, they take it in the first place. I was wondering how can I do this. I will provide another practical example with code:

  // default launcher increases public square ScreenA activity {ListView listView; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); SetContentView (R.layout.selectactivity); // Get the ListView object from the XML listview = (list view) findViewById (R.id.listView); // set array value to show in the list string [] value = new string [] {"b", "c", "d", "e"}; ArrayAdapter & LT; String & gt; Adapter = new array adapter & lt; String & gt; (This, Android R Outout. Simple_L_Litimi, AndroidRID.Text1, Value); // Assign the adapter to ListView listView.setAdapter (adapter); // ListView Item Click Listener listView.setOnItemClickListener (New AdapterView.OnItemClickListener () {@Override Public Zero onItemClick (View AdapterView & LT;; & Gt; Parents, View, Integer Status, Long ID) {int itemPosition = Status ; String itemValue = (string) listView.getItemAtPosition (status), if (itemValue.equals ("B")) {end;); nextScreen = new intent (getApplicationContext (), B.class); startActivity (nextScreen); } Else if is equal to itemValue ('c')) {end (;); nextScreen = new intent (getApplicationContext (), B.class); startActivity (nextScreen);} else if (itemValue.equals (' D ')) {end (); intent next screen = no Intent (getApplicationContext (), D. class); startActivity (nextScreen);} and if (M.Engles ("E")) {Finnish}; the next screen = new intent (getApplicationContext (E. Class)); StartActivity (nextScreen);}}}); }}  

If the user selects one of these options, they are directed to the screen that they select when they leave the app and come back later, Because of the screen, they choose the load with the list of items instead of the screen. . They want to select another screen later, they can go to settings and choose whatever screen they like (I already have a button for list view in one of the action bar overflow options).

Scenario: If the user selects "B", they are taken to the screen "B" if they close the application, then turn the phone off, and later come back to the application, Instead of the screen "A" The screen "B" will load.

PS: I've removed a lot of code and try to simplify it with the actual code instead of the name. If there is a problem with the code, please let me know.

After

Your default activity is set to appear, and this can not be changed. Can turn into some kind of launcher, which will open activity A, B or C.

To find out which activity to open, you can send the last open activity to SharedPreferences

If you need to save the state of activity, you can use onSaveInstanceState ()


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -