应用升级后应用是否启动 LAUNCH Activity?
Does app launch LAUNCH Activity after app upgrade?
在我的下一个应用程序版本中,我需要一个布尔标志 enableNotification
。因此,为了在用户在 MainActivity 中启动我的应用程序后在我的应用程序中一切正常,它将此标志设置为 false 并将其保存到 SharedPreferences。如果它不转到 MainActivity 并将此标志设置为 Shared,我的应用程序将无法运行。
所以我的问题是用户在 Google Play 上将他的应用程序升级到较新版本后(旧版本在 SharedPref 中没有此标志),是否会先转到 MainActivity 而不是用户之前的 Activity(第二个 Activity、第三个 Activity...)?或者最好将这个标志保存到数据库中,所以在 onCreate()
中将这个标志设置为 false?
如果您的应用依赖于 SharedPreference 'enableNotification' 才能工作,那么您需要先在 Application class 中进行检查。
如果应用程序之前没有值,请先初始化应用程序 class 中的值。在应用程序 onCreate()
中进行检查,因为应用程序 class 在 Activity 之前被调用,如文档所述:
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().
更新应用 Android 强制关闭它。
因此,下次用户打开应用程序时,它将启动您在 Android 清单中使用 ACTION_MAIN Intent Filter 声明的 Activity(可能是 MainActivity
)
在我的下一个应用程序版本中,我需要一个布尔标志 enableNotification
。因此,为了在用户在 MainActivity 中启动我的应用程序后在我的应用程序中一切正常,它将此标志设置为 false 并将其保存到 SharedPreferences。如果它不转到 MainActivity 并将此标志设置为 Shared,我的应用程序将无法运行。
所以我的问题是用户在 Google Play 上将他的应用程序升级到较新版本后(旧版本在 SharedPref 中没有此标志),是否会先转到 MainActivity 而不是用户之前的 Activity(第二个 Activity、第三个 Activity...)?或者最好将这个标志保存到数据库中,所以在 onCreate()
中将这个标志设置为 false?
如果您的应用依赖于 SharedPreference 'enableNotification' 才能工作,那么您需要先在 Application class 中进行检查。
如果应用程序之前没有值,请先初始化应用程序 class 中的值。在应用程序 onCreate()
中进行检查,因为应用程序 class 在 Activity 之前被调用,如文档所述:
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().
更新应用 Android 强制关闭它。
因此,下次用户打开应用程序时,它将启动您在 Android 清单中使用 ACTION_MAIN Intent Filter 声明的 Activity(可能是 MainActivity
)