【发布时间】:2017-08-26 17:39:35
【问题描述】:
嘿,有没有在用户第一次打开应用程序后每 15 天发送一次通知?提前致谢
【问题讨论】:
-
答案很残酷:必须写代码。
嘿,有没有在用户第一次打开应用程序后每 15 天发送一次通知?提前致谢
【问题讨论】:
您可以在 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
【讨论】: