Thread downloadThread = new Thread() {
@Override
public void run() {
int flagSong = download.downloadFile(songFile);
download.setUrl_path(urlLrc);
int flagLrc = download.downloadFile(lrcFile);
int flag = flagSong + flagLrc;
Notification notification;
if (flag == 2) {
notification = new Notification(android.R.id.icon2,
"download", java.lang.System.currentTimeMillis());
notification.setLatestEventInfo(RemoteMp3Activity.this,
"下载", "下载完成", null);
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.defaults = Notification.DEFAULT_SOUND;
} else {
notification = new Notification(
android.R.drawable.arrow_up_float, "download",
java.lang.System.currentTimeMillis());
Intent notificationIntent = new Intent(
RemoteMp3Activity.this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
RemoteMp3Activity.this, 0, notificationIntent, 0);
notification.setLatestEventInfo(RemoteMp3Activity.this,
"下载", "下载未完成", pendingIntent);
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.defaults = Notification.DEFAULT_SOUND;
}
manager.notify(SONG_DOWNLOAD, notification);
}
};
代码notificationjava