java - Is there a way to find out how long an app is installed? -
java - Is there a way to find out how long an app is installed? -
i find out how long app installed on device.
the reason : announce new update app users have installed app longtime ago , want prevent announce users, have installed app. hate myself advertising in apps :-) want discreet , show proclamation users have installed app longtime ago. (sorry bad english)
what not want utilize following, because allow me observe newer version, implemented it: - using google analytics. - counter counts appstarts in property
i looking solution implement in 2014 , detects app installed since 2013.
any hints ?
the easiest way moving forwards pair of sharedpreferences
:
sharedpreferences prefs = preferencemanager.getdefaultsharedpreferences(new context()); boolean firstrun = prefs.getboolean("is_first_run", true); long = system.currenttimemillis(); if (firstrun) { sharedpreferences.editor editor = prefs.edit(); editor.putboolean("is_first_run", false); editor.putlong("first_run_millis", now); editor.apply(); } else { long datefirstrun = prefs.getlong("first_run_millis", 0l); if (datefirstrun == 0l) { // no value saved. decide how want handle } else if (now - datefirstrun < some_age) { // offer functionality } }
if want check past installs think have play packagemanager
edit: richard suggests in comments above:
try { long firstinstall = context.getpackagemanager().getpackageinfo("package.name", 0).firstinstalltime; } grab (packagemanager.namenotfoundexception e) { e.printstacktrace(); }
java android apk
Comments
Post a Comment