public class DownloadNotification extends Object
Modifier and Type | Field and Description |
---|---|
private PendingIntent |
mContentIntent |
private CharSequence |
mContentTitle |
private Context |
mContext |
private Notification |
mNotification |
private NotificationManager |
mNotificationManager |
private int |
NOTIFICATION_ID |
Constructor and Description |
---|
DownloadNotification(Context context) |
Modifier and Type | Method and Description |
---|---|
void |
completedDownload(String directoryPath,
String fileName)
Called when the downloading task is complete.
|
void |
createNotification(String fileName)
Creates an ongoing notification into the status bar
This notification will be updated while downloading with the percent downloaded
|
void |
eraseNotification(String fileName)
Called when the downloading task could not be completed
It removes the ongoing notification and creates a new static notification.
|
private Intent |
openFileDefaultApp(String absolutePath)
It is defined an Intent to open the file located in @a absolutePath with the default app associated with its extension
|
void |
progressUpdate(int percentageComplete)
Receives progress updates from the background task and updates the status bar notification appropriately
|
private final Context mContext
private final int NOTIFICATION_ID
private Notification mNotification
private final NotificationManager mNotificationManager
private PendingIntent mContentIntent
private CharSequence mContentTitle
public DownloadNotification(Context context)
public void createNotification(String fileName)
fileName
- name of file that is downloading. It is show on the notification.public void progressUpdate(int percentageComplete)
percentageComplete
- public void completedDownload(String directoryPath, String fileName)
directoryPath
- directory where the downloaded file is storedfileName
- name of the just downloaded filepublic void eraseNotification(String fileName)
private Intent openFileDefaultApp(String absolutePath)