I'm creating a foreground service with an indeterminate progress bar
.
public Notification createNotification() {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_TEST)
.setSmallIcon(R.drawable.ic_download_complete)
.setContentTitle("Test title")
.setContentText("Test content")
.setProgress(someInt, someInt, true) //What do I set for these two params before the boolean flag
.setPriority(NotificationCompat.PRIORITY_LOW)
.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = this.getSystemService(NotificationManager.class);
NotificationChannel channel = new NotificationChannel(
CHANNEL_TEST,
"Test notification",
NotificationManager.IMPORTANCE_LOW
);
notificationManager.createNotificationChannel(channel);
notificationManager.notify(NOTIFICATION_ID, builder.build());
}
return builder.build();
}
I'm trying to understand what values I have to set for the two int params in .setProgress
. The last boolean flag in the method is for setting it as an determinate or indeterminate progressbar
. So if it's a determinate, we can update the two ints to the percent we want .setProgress(100, 10, true)
, but for indeterminate what should I set the values as?
I tried checking the method but it doesn't quite say what to use for indeterminate. Since passing null is not an option
CodePudding user response:
To display an indeterminate progress bar (a bar that does not indicate percentage complete), call setProgress(0, 0, true). The result is an indicator that has the same style as the progress bar above, except the progress bar is a continuous animation that does not indicate completion.
So, you need to set the two int
values to 0