alla
alla

Reputation: 549

Does app launch LAUNCH Activity after app upgrade?

In my next app version I need to have a boolean flag enableNotification. So in order everything works fine in my app after user launches my app in MainActivity it sets this flag to false and I saves it to SharedPreferences. If it doesn't go to MainActivity and sets this flag to Shared my app will work wrong.

So my question is whether after user upgrades his app on Google Play to the newer version (the old version doesn't have this flag in SharedPref), will it go first to MainActivity and not to the Activity the user was before (SecondActivity, ThirdActivity...)? Or it's better to save this flag to the DB, so in onCreate() set this flag to false?

Upvotes: 1

Views: 392

Answers (2)

ElegyD
ElegyD

Reputation: 4785

Updating an App on Android force closes it.
So the next time the user opens the app, it will start the Activity that you declared with the ACTION_MAIN Intent Filter in the Android Manifest (probably MainActivity)

Upvotes: 2

ישו אוהב אותך
ישו אוהב אותך

Reputation: 29794

If your app depends on the SharedPreference 'enableNotification' to works, then you need to do the checking in Application class first.

Initialize the value in Application class first if the app never have the value before. Do the checking in application onCreate() because Application class is called before Activity as the documentation says:

void onCreate ()

Called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created. Implementations should be as quick as possible (for example using lazy initialization of state) since the time spent in this function directly impacts the performance of starting the first activity, service, or receiver in a process. If you override this method, be sure to call super.onCreate().

Upvotes: 2

Related Questions