Hello there I am newbie in Android Development. What I am trying to do is:
- Downloading a file using a URL
- Placed it in my downloads
- Used a Download Manager within IntentService for downloading
- Upon completion of the downloading, I am showing a Notification
- The notification notify's the user for the download completion
The problem is that I want the user to tap on the generated notification, and to open the Downloads Folder!
What I have been trying is:
public void sendNotification() {
// Use NotificationCompat.Builder to set up our notification.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
//icon appears in device notification bar and right hand corner of notification
builder.setSmallIcon(R.drawable.downloaded);
// This intent is fired when notification is clicked
*****Here I want the user if clicks this notification the Download Folder should Open up*****
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri imgUri = Uri.fromFile(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS));
intent.setDataAndType(imgUri, "file/*");
startActivity(intent);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
// Set the intent that will fire when the user taps the notification.
builder.setContentIntent(pendingIntent);
// Large icon appears on the left of the notification
builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.downloaded));
// Content title, which appears in large type at the top of the notification
builder.setContentTitle("Complete");
// Content text, which appears in smaller text below the title
builder.setContentText("Your Download has been completed Successfully!");
//set the subtext
builder.setSubText("Click to open the Downloads Folder!");
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Will display the notification in the notification bar
notificationManager.notify(NOTIFICATION_ID, builder.build());
}
Whenever I clicked on it nothing happend!
I am new to Android, kindly review my mistake so that I can learn more. This is not an assignment, I am learning it to myself! Thanks in advance.