gpt4 book ai didi

Android:安装一天后如何显示按钮?

转载 作者:行者123 更新时间:2023-11-29 15:57:05 24 4
gpt4 key购买 nike

我的主要 Activity 中有一个按钮。默认情况下它是不可见的,但我想让它在安装我的应用程序后一天(或第一次运行我的应用程序后一天)可见。所以当用户安装我的应用程序时,他看不到我的按钮。但是安装后的一天,他可以看到我的按钮。我该怎么做?

最佳答案

这里是解决方案...首先获取安装日期,然后将该日期与当前日期进行比较。如果超过 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();

}

关于Android:安装一天后如何显示按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27457200/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com