DownloadCompleteService uses same notification code as DownloadService.

Both classes required the same type of notification intent to be
created, so they now both use the same static function to create
the relevant intent.
This commit is contained in:
Peter Serwylo 2016-04-21 13:30:33 +10:00
parent 0163d6efa6
commit 8794611b26

View File

@ -64,22 +64,13 @@ public class DownloadCompleteService extends IntentService {
title = String.format(getString(R.string.tap_to_install_format), app.name); title = String.format(getString(R.string.tap_to_install_format), app.name);
} }
Intent notifyIntent = new Intent(this, AppDetails.class);
notifyIntent.putExtra(AppDetails.EXTRA_APPID, packageName);
TaskStackBuilder stackBuilder = TaskStackBuilder
.create(this)
.addParentStack(AppDetails.class)
.addNextIntent(notifyIntent);
int requestCode = Utils.getApkUrlNotificationId(intent.getDataString()); int requestCode = Utils.getApkUrlNotificationId(intent.getDataString());
PendingIntent pendingIntent = stackBuilder.getPendingIntent(requestCode,
PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = NotificationCompat.Builder builder =
new NotificationCompat.Builder(this) new NotificationCompat.Builder(this)
.setAutoCancel(true) .setAutoCancel(true)
.setContentTitle(title) .setContentTitle(title)
.setSmallIcon(android.R.drawable.stat_sys_download_done) .setSmallIcon(android.R.drawable.stat_sys_download_done)
.setContentIntent(pendingIntent) .setContentIntent(DownloaderService.createAppDetailsIntent(this, requestCode, packageName))
.setContentText(getString(R.string.tap_to_install)); .setContentText(getString(R.string.tap_to_install));
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify(Utils.getApkUrlNotificationId(intent.getDataString()), builder.build()); nm.notify(Utils.getApkUrlNotificationId(intent.getDataString()), builder.build());