Android 4: can't dismiss notification by swiping

前端 未结 3 1429
庸人自扰
庸人自扰 2020-12-10 14:19

I have some code that creates some notifications, it\'s really basic.

int icon = R.drawable.notification;
CharSequence tickerText = \"Text\";
long when = Sys         


        
3条回答
  •  天涯浪人
    2020-12-10 15:08

    You should use setOngoing (boolean ongoing)

    Set whether this is an "ongoing" notification. Ongoing notifications cannot be dismissed by the user, so your application or service must take care of canceling them. They are typically used to indicate a background task that the user is actively engaged with (e.g., playing music) or is pending in some way and therefore occupying the device (e.g., a file download, sync operation, active network connection).

    You can use

    .setOngoing(false);
    

提交回复
热议问题