如何在Android中锁定通知点击屏幕?

时间:2017-08-10 09:03:09

标签: android-activity push-notification android-notifications

如何通过点击我的应用程序的通知来锁定我的屏幕?

 public void openNotification(View v) {
 //This is to notification
    Intent intent = new Intent();
    PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
    Notification noti = new Notification.Builder(this)
            .setContentTitle("Easy Lock")
            .addAction()
            //.setActions()
            .setAutoCancel(false)
            .setOngoing(true)
            .setContentText("Press Here to Lock Your Screen")
            .setSmallIcon(R.drawable.logo)
            .setContentIntent(pIntent).getNotification();
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(0, noti);

0 个答案:

没有答案