小编Con*_*den的帖子

在特定时间Android发送给用户的通知

我正在尝试使用Alarm Manager在特定时间向用户发送通知.基本上没有任何事情发生,对我来说代码看起来很好.我的警报管理器代码如下:

/** Notify the user when they have a task */
public void notifyAtTime() {
    Intent myIntent = new Intent(PlanActivity.this , Notification.class);     
    AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
    PendingIntent pendingIntent = PendingIntent.getService(PlanActivity.this, 0, myIntent, 0);

    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 12);
    calendar.set(Calendar.MINUTE, 17);
    calendar.set(Calendar.SECOND, 00);

    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 24*60*60*1000 , pendingIntent);
}
Run Code Online (Sandbox Code Playgroud)

通知的代码位于"通知"类中,如下所示:

    public class Notification extends Service {


    @Override
    public void onCreate() {   

        Toast.makeText(this, "Notification", Toast.LENGTH_LONG).show();

        Intent intent = new Intent(this,PlanActivity.class);
        PendingIntent pending = PendingIntent.getActivity(this, 0, intent, 0);
        NotificationCompat.Builder mBuilder = …
Run Code Online (Sandbox Code Playgroud)

notifications android alarmmanager

11
推荐指数
1
解决办法
2万
查看次数

将MongoDB文档值传递给EJS表

我是node.js和MongoDB的新手,所以请耐心等待.我有一个表格,可以将细节存储到MongoDB集合中; 然后我使用.findOne(现在)查询.我基本上试图将此值传递到我的index.ejs文件中并将其显示为表的一部分.所以表格应该出现:

名称:Web浏览器中的Connor.

我查询数据库的代码:

router.get('/', function(req, res) {
    res.render('admin/index');

    MongoClient.connect("mongodb://localhost:27017/tickets", function(err, db) {
        // Ensure we have connected
        if(err) {
            console.log("Cannot connect to database");
        } else {
            console.log("Connected to database");
        }
        // Create a collection to query
        var collection = db.collection('tickets');
        collection.findOne({name:String}, function(err, item) {
            // Ensure we have found the ticket
            if(err) {
                console.log("There was a problem finding the ticket.");
            } else {
                console.log("Ticket found!");
            }
        });
    });
});
Run Code Online (Sandbox Code Playgroud)

我的代码生成表:

<table>
    <thead>
        <tr>
            <th>Name</th>
            <th>Email</th>
            <th>Subject</th>
            <th>Message</th>
        </tr>
    </thead> …
Run Code Online (Sandbox Code Playgroud)

javascript node.js node-mongodb-native

-1
推荐指数
1
解决办法
3094
查看次数