Android 如何使用从数据库检索的内容显示通知?
我正在用Android做一个笔记应用,它有一个标题和一个主体,用户可以保存到SQLite数据库中。还有一个选项可用于保存带有提醒的便笺 如何显示通知,例如,通知标题作为数据库中的注释标题,通知正文作为数据库中的正文 我的数据库具有每个注释的属性id、text和body 如何显示正确的ID以及用户何时单击通知? 如何仅打开特定便笺?查看此信息 这将帮助您显示一个简单的通知Android 如何使用从数据库检索的内容显示通知?,android,Android,我正在用Android做一个笔记应用,它有一个标题和一个主体,用户可以保存到SQLite数据库中。还有一个选项可用于保存带有提醒的便笺 如何显示通知,例如,通知标题作为数据库中的注释标题,通知正文作为数据库中的正文 我的数据库具有每个注释的属性id、text和body 如何显示正确的ID以及用户何时单击通知? 如何仅打开特定便笺?查看此信息 这将帮助您显示一个简单的通知 public class StatusBar extends Activity implements OnClickListe
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();
}
}好的。我明白了,谢谢!如何使用AlarmManager为指定时间安排闹钟?有很多方法可以做到这一点。。。我有一个报警应用程序,我正在使用da应用程序中的广播服务