如果应用正在运行,我需要我的应用在一天的特定时间为用户显示消息。如何引用用户设备的当前时间?非常感谢!
答案 0 :(得分:1)
您可以使用NSDate类来获取当天的时间。例如:
Realm localRealm = Realm.getInstance(RealmUtility.getRealmConfig(mContext));
try {
TotalTransaction totalTransaction = localRealm.where(TotalTransaction.class).equalTo("pk", totalTransactionPk).findFirst(); // returning null so doesn't enter inside if block
if (totalTransaction != null && totalTransaction.isLoaded()) {
// run algorithm and other related works based on realm results
} catch (Exception e) {
e.printStackTrace();
} finally {
if (localRealm != null) localRealm.close();
}