【发布时间】:2012-11-05 17:46:12
【问题描述】:
我创建了一个状态栏通知,它会在状态栏上给我一些消息,单击该消息会重定向到一个全新的布局。 状态条码 -
NotificationManager mgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(this, TaskCompleteActivity.class);
notificationIntent.putExtra(TasksDBAdapter.KEY_ROWID, rowId);
notificationIntent.putExtra(TasksDBAdapter.KEY_TITLE, taskTitle);
notificationIntent.putExtra(TasksDBAdapter.KEY_BODY, taskDesc);
//notificationIntent.putExtra("NotificationId", );
Log.i(TAG,"rowId in doReminderWork" + rowId);
PendingIntent pi = PendingIntent.getActivity(this, 0, notificationIntent,PendingIntent.FLAG_ONE_SHOT);
Notification note=new Notification(android.R.drawable.stat_sys_warning,taskDesc,System.currentTimeMillis());
note.setLatestEventInfo(this, taskTitle,taskDesc, pi);
note.defaults |= Notification.FLAG_AUTO_CANCEL;
note.defaults |= Notification.DEFAULT_SOUND;
note.defaults |= Notification.DEFAULT_VIBRATE;
// you need to clear the notification on click of status bar notification //
note.flags |= Notification.FLAG_NO_CLEAR;
// An issue could occur if user ever enters over 2,147,483,647 tasks. (Max int
// value).
// I highly doubt this will ever happen. But is good to note.
int id = (int)((long)rowId);
mgr.notify(id, note);
此布局有一个名为 Complete on click 的按钮,我正在删除数据库中的一行并调用 finish()。代码 -
public void completeTask(){
taskDBAdapter.deleteReminder(rowId);
this.finish();
}
在此之后,如果我从普通菜单打开我的应用程序,它仍然会显示相同的布局,其中包含完整的按钮,而不是我的登陆活动。为什么这个活动没有完成?
提前致谢, 考希克
【问题讨论】:
-
您可能需要发布更多代码。仅从这两个陈述很难看出发生了什么。
-
请看一下,如果需要更多详细信息,请告诉我
标签: android android-intent android-notifications