这里是解决方案...
首先获取安装日期,然后将该日期与当前日期进行比较。如果超过 1 天,您可以显示您的按钮。
这里是代码...
// ****************** To know installation date of application for button show **************//
try {
appInstalledDate = Splash.this.getPackageManager().getPackageInfo("your package name", 0).firstInstallTime;
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM,yyyy HH:mm");
Date resultdate = new Date(appInstalledDate);
Log.v("Installation date of app is ",","+resultdate);
} catch (Exception e) {
e.printStackTrace();
}
在这里你可以显示你的按钮
try {
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");
Date resultdate = new Date(Long.parseLong(prefs.getString("email_prompt", "")));
Log.v("current date ",","+sdf.format(new Date().getTime()));
long diff = new Date().getTime() - resultdate
long diffMinutes = (diff / 1000) / 60;
long diffMinutes = (TimeUnit.MILLISECONDS.toMinutes(diff));
Log.v("Difference in minutes is ",","+diffMinutes);
if(1440 < diffMinutes)
{
yourButton.show(); // show your button
}
} catch (Exception e) {
e.printStackTrace();
}