当前位置: 代码迷 >> Android >> 关于notification的使用失误
  详细解决方案

关于notification的使用失误

热度:58   发布时间:2016-04-28 07:37:55.0
关于notification的使用出错
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);
}
};

代码
notification java

------解决方案--------------------
if?(flag?==?2)?{   里面的contentIntent为空  看log应该是这个原因
LZ是2.3下的代码吧  设置contentIntent吧   不然报错的  4.0可以为空
  相关解决方案