change the activity property

  • Replies:3
karam alem
  • Forum posts: 2

Jun 26, 2012, 8:36:59 AM via Website

Hi every one

I have three activities

the first one:
there is just a button if the user press the button it will transfer him to the second activity, and this is the default activity.

the second one:
there is many edit texts and a spinner item and tow button if the user press the save button it will saved the entered data to a shared preference and transfer him to the third activity

the third one:
it is a list activity and the list will load the shared preference.

the question is :
how can I change the default activity from the first one to the third one if the user saved at least one shared preference so when the user open the app again the third activity should appear to him ??

and thanks...

Reply
Jeremiah
  • Forum posts: 775

Jun 26, 2012, 6:12:33 PM via Website

The activity that is opened on launch is specified in the manifest. And I don't think you can change your manifest programatically once the .apk has been built. What you could do is on the onCreate method of the first activity is check the shared preferences for previous data, then open the 3rd activity. The first activity may flash on the screen for a second or two, before the 3rd activity is shown, but I don't know a better way.

karam alem

Reply
karam alem
  • Forum posts: 2

Jul 7, 2012, 8:13:43 AM via Website

thank u very much

I'll try...

I appreciate that

Reply
Jeremiah
  • Forum posts: 775

Jul 7, 2012, 6:54:54 PM via Website

Your welcome ;) I've thought of another thing too... Try putting the code to check for shared preferences and change the activity in your main activities onCreate BEFORE the:

setContentView(R.layout.main);

This may keep it from showing the main activity at all before the appropriate activity pops up.

Reply