我在Android中制作了一个笔记应用程序,它有一个标题和一个用户可以保存到SQLite数据库的正文。还可以选择通过提醒保存笔记。
如何显示通知,例如,通知的标题是数据库中的注释标题,以及通知的正文是数据库中的正文?
我的数据库有每个音符的属性id,文本,正文。
如何在用户点击通知时显示正确的ID? 如何仅打开特定注释?
答案 0 :(得分:1)
检查出来
这可以帮助您显示简单的通知
public class StatusBar extends Activity implements OnClickListener{
NotificationManager nm;
static final int uniqueID = 1394885;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.statusbar);
Button stat = (Button)findViewById(R.id.bStatusBar);
stat.setOnClickListener(this);
nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.cancel(uniqueID);
}
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(this, StatusBar.class);
PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);
String body = "This is a message from Travis, thanks for your support";
String title = "Travis C.";
Notification n = new Notification(R.drawable.lightning, body, System.currentTimeMillis());
n.setLatestEventInfo(this, title, body, pi);
n.defaults = Notification.DEFAULT_ALL;
nm.notify(uniqueID, n);
finish();
}
}