Ideas:
1. Based on sharedpreferences, each time you open, you can distinguish this open situation according to the version recorded on the last Open.
Storeddata.java:
1.application.oncreate call Storeddata.getthis (). Markopenapp (); Other locations can be opened according to the Getlaunchmode judgment open type.
Package Com.example.test;import Android.app.application;import Android.content.sharedpreferences;import Android.content.pm.packageinfo;import Android.content.pm.packagemanager;import Android.text.TextUtils;public Class Storeddata {public static final int lmode_new_install = 1;//start-mode, first install-first boot, overwrite installation-first boot, installed-two start public static final int lmode_update = 2;public static final int lmode_again = 3;private Boolean isopenmarked = false;private int launchmode = Lmode_again; Start-mode private static Storeddata instance;private sharedpreferences share; General information public static Storeddata Getthis () {if (instance = = null) instance = new Storeddata (); return instance;} -------Boot status------------------------------------------------------------//mark-open app to generate-whether to open public void for the first time Markopenapp () {//Prevent-repeat call if (isopenmarked) return;isopenmarked = true; String lastversion = share.getstring ("Lastversion", "" "); String thisversion = Getappversion ();//First start if (Textutils.isempty (lastversion)) {Launchmode = Lmode_new_instalL;share.edit (). putstring ("Lastversion", thisversion). commit ();} Update else if (!thisversion.equals (lastversion)) {Launchmode = Lmode_update;share.edit (). putstring ("Lastversion", thisversion). commit ();} Two start (version unchanged) Elselaunchmode = Lmode_again;} public int Getlaunchmode () {return launchmode;} First open, new installation, overwrite (different version number) public Boolean isfirstopen () {return launchmode! = Lmode_again;} -------------------------//Software-version public static string Getappversion () {String versionname = ""; Application app = Myapplication.getthis (); try {Packagemanager pkgmng = App.getpackagemanager (); PackageInfo pkgInfo = Pkgmng.getpackageinfo (App.getpackagename (), 0); versionname = Pkginfo.versionname;} catch (Exception e) {//Todo:handle exceptione.printstacktrace ();} return versionname;}}