Slow down progress events to ensure notification action button can be pressed.
After much consternation and testing, it became apparant that there was nothing really wrong with our PendingIntent setup or notification setup. The only problem was the rapidness with which the notification was being updated. There is something about rapidly updated notificaitons which makes it not possible to hit the action button. This explains why the button _would indeed work sometimes_, because the user may have hit it just in that sweet spot. This change increases the time between progress events from 100ms to 500ms which seems to do the job on my Moto X 2nd gen. Perhaps this can be changed to a larger number if required. When it was set to 300 ms, it _mostly_ worked, but there was still a few times where hitting the button wouldn't work at all. Fixes #652.
This commit is contained in:
parent
f1b09a5c43
commit
b3f79da341
@ -145,7 +145,7 @@ public abstract class Downloader {
|
|||||||
totalBytes = totalDownloadSize();
|
totalBytes = totalDownloadSize();
|
||||||
byte[] buffer = new byte[bufferSize];
|
byte[] buffer = new byte[bufferSize];
|
||||||
|
|
||||||
timer.scheduleAtFixedRate(progressTask, 0, 100);
|
timer.scheduleAtFixedRate(progressTask, 0, 500);
|
||||||
|
|
||||||
// Getting the total download size could potentially take time, depending on how
|
// Getting the total download size could potentially take time, depending on how
|
||||||
// it is implemented, so we may as well check this before we proceed.
|
// it is implemented, so we may as well check this before we proceed.
|
||||||
|
@ -147,8 +147,7 @@ public class DownloaderService extends Service {
|
|||||||
public static PendingIntent getCancelPendingIntent(Context context, String urlString) {
|
public static PendingIntent getCancelPendingIntent(Context context, String urlString) {
|
||||||
Intent cancelIntent = new Intent(context.getApplicationContext(), DownloaderService.class)
|
Intent cancelIntent = new Intent(context.getApplicationContext(), DownloaderService.class)
|
||||||
.setData(Uri.parse(urlString))
|
.setData(Uri.parse(urlString))
|
||||||
.setAction(ACTION_CANCEL)
|
.setAction(ACTION_CANCEL);
|
||||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
|
|
||||||
return PendingIntent.getService(context.getApplicationContext(),
|
return PendingIntent.getService(context.getApplicationContext(),
|
||||||
urlString.hashCode(),
|
urlString.hashCode(),
|
||||||
cancelIntent,
|
cancelIntent,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user