【问题标题】:How to send an notification 15 days after user opens the app for the first time [closed]如何在用户首次打开应用程序后 15 天发送通知 [关闭]
【发布时间】:2017-08-26 17:39:35
【问题描述】:

嘿,有没有在用户第一次打开应用程序后每 15 天发送一次通知?提前致谢

【问题讨论】:

  • 答案很残酷:必须写代码。

标签: java android


【解决方案1】:

您可以在 MainActivity.java 的 OnCreate 中使用 SharedPreferences 保存应用程序的首次运行日期。

然后你可以使用日历对象来获取这样的一天

SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
int start = sharedPref.getInt("firstRunDate", 0);
   Calender cal = Calendar.getInstance();
    int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH)+1;

if((dayOfMonth+15)%30 == start)
//send notifications

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多