亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

for循環,下載進度一直有聲音啊,怎么解決?

for?(int?i?=?0;?i?<?100;?i++)?{
????????????????????try?{
????????????????????????Thread.sleep(1000);//1秒后更新一下
????????????????????????builder.setDefaults(Notification.FLAG_ONLY_ALERT_ONCE);
????????????????????????//設置進度,max最大進度值,progress當前進度,indeterminate不確定的
????????????????????????builder.setProgress(100,i,false);
????????????????????????getManager().notify(2,builder.build());
????????????????????}?catch?(InterruptedException?e)?{
????????????????????????e.printStackTrace();
????????????????????}
????????????????}


正在回答

1 回答

Notification.Builder?builder?=?new?Notification.Builder(this)
????????.setAutoCancel(true)
????????.setChannelId("test_channel_id")
????????.setContentTitle("新消息來了")
????????.setContentText("明天是周末,不用上班?你怕是在做夢!")
????????.setOnlyAlertOnce(true)
????????.setSmallIcon(R.mipmap.ic_launcher);

manager.notify(1,?builder.build());

new?Thread(new?Runnable()?{
????@Override
????public?void?run()?{
????????for?(int?i?=?0;?i?<?100;?i++)?{
????????????try?{
????????????????Thread.sleep(1000);
????????????????builder.setProgress(100,?i,?false);

????????????????manager.notify(1,?builder.build());
????????????}?catch?(InterruptedException?e)?{
????????????????e.printStackTrace();
????????????}

????????}
????}
}).start();

設置builder.setDefaults(Notification.FLAG_ONLY_ALERT_ONCE);這個是沒有效果的


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Android O(8.0)通知欄解決方案
  • 參與學習       6673    人
  • 解答問題       5    個

本課程主要介紹Android 8.0 ChannelNotification的管理。

進入課程

for循環,下載進度一直有聲音啊,怎么解決?

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號