【发布时间】:2017-11-13 07:17:15
【问题描述】:
我有一个通知生成器。我想添加通知计时器,例如 whatsapp 呼叫通知。所以如果我调用 updateNotifTime 函数,是行不通的。
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, callChannelId)
.setSmallIcon(R.drawable.call_icon)
.setContentIntent(pendingIntent)
.setOngoing(true)
.setShowWhen(true)
.setWhen(System.currentTimeMillis())
.setPriority(NotificationCompat.PRIORITY_HIGH);
public void updateNotifTime() {
this.callingElapsedRunnable = new Runnable() {
@Override
public void run() {
elapsedTime += 1000;
String timer = DateUtils.calculateTime(elapsedTime);
builder.setWhen(elapsedTime);
callingElapsedHandler.postDelayed(this, 1000);
}
};
callingElapsedHandler.postDelayed(callingElapsedRunnable, 1000);
}
【问题讨论】:
-
尝试使用:.setUsesChronometer(true) 提示:developer.android.com/reference/android/app/…
-
我试过了但还是不行:(
-
哦,可以试试并行使用吗:setChronometerCountDown(boolean)
-
setChronometerCountDown(boolean) 未定义
-
.setChronometerCountDown(true)
标签: android timer notifications call