summaryrefslogtreecommitdiffstats
path: root/Android/06-Notifications/Notifications/src/course/labs/notificationslab/DownloaderTask.java
diff options
context:
space:
mode:
Diffstat (limited to 'Android/06-Notifications/Notifications/src/course/labs/notificationslab/DownloaderTask.java')
-rw-r--r--Android/06-Notifications/Notifications/src/course/labs/notificationslab/DownloaderTask.java28
1 files changed, 8 insertions, 20 deletions
diff --git a/Android/06-Notifications/Notifications/src/course/labs/notificationslab/DownloaderTask.java b/Android/06-Notifications/Notifications/src/course/labs/notificationslab/DownloaderTask.java
index b792b38..655d93a 100644
--- a/Android/06-Notifications/Notifications/src/course/labs/notificationslab/DownloaderTask.java
+++ b/Android/06-Notifications/Notifications/src/course/labs/notificationslab/DownloaderTask.java
@@ -147,15 +147,9 @@ public class DownloaderTask extends AsyncTask<String, Void, String[]> {
log("Entered result receiver's onReceive() method");
- // TODO: Check whether the result code is RESULT_OK
+ if (getResultCode() == Activity.RESULT_OK) {
- if (/*change this*/ true) {
-
- // TODO: If so, create a PendingIntent using the
- // restartMainActivityIntent and set its flags
- // to FLAG_UPDATE_CURRENT
-
- final PendingIntent pendingIntent = null;
+ final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
// Uses R.layout.custom_notification for the
// layout of the notification View. The xml
@@ -164,19 +158,13 @@ public class DownloaderTask extends AsyncTask<String, Void, String[]> {
mApplicationContext.getPackageName(),
R.layout.custom_notification);
- // TODO: Set the notification View's text to
- // reflect whether or the download completed
- // successfully
-
- // TODO: Use the Notification.Builder class to
- // create the Notification. You will have to set
- // several pieces of information. You can use
- // android.R.drawable.stat_sys_warning
- // for the small icon. You should also setAutoCancel(true).
-
- Notification.Builder notificationBuilder = null;
+ mContentView.setTextViewText(R.id.text, successMsg);
- // TODO: Send the notification
+ Notification.Builder notificationBuilder = new Notification.Builder(context);
+ notificationBuilder.setContentIntent(pendingIntent);
+ notificationBuilder.setContent(mContentView);
+ notificationBuilder.setSmallIcon(android.R.drawable.stat_sys_warning);
+ notificationBuilder.setAutoCancel(true);
log("Notification Area Notification sent");
}