点击服务前台通知Android的事件

时间:2015-05-29 20:30:13

标签: android service notifications

我有一个前台通知服务。 当用户点击前景通知时如何启动活动?

我尝试过:

// CREATE NOTIFICATION FOREGROUND
    Intent notificationIntent = new Intent(getApplicationContext(), HomeActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);
    Notification notification = new NotificationCompat.Builder(getApplicationContext())
            .setContentTitle("Title")
            .setTicker("Test service")
            .setContentIntent(contentIntent)
            .setContentText("text...").build();
    startForeground(1, notification);
    //======================================================================================

我需要在用户点按前台通知时启动HomeActivity。

0 个答案:

没有答案