安卓通知
我的要求是需要在上传可用时显示通知。Each &每次进入新的 Activity 时,都会检查上传是否可用。(上传的意思是:如果 android 数据库中发生任何更改,则表明需要上传到实际的 sql server 数据库)。
查看我的代码:
uploadSize = new UploadActivity().getUploadTable();
if(uploadSize > 0){
Button button = (Button) findViewById(R.id.u);
button.setBackgroundColor(Color.RED);
long whenTo = System.currentTimeMillis();
Notification n = new Notification(R.drawable.icon, "", whenTo);
n.tickerText = "TV Spored ++";
String contentTitle = "I am expanded title";
String contentText = "I am expanded text";
Intent intent = new Intent(this, NotificationReceiver.class);
// Put additional stuff into the created intent
PendingIntent contentIntent = PendingIntent.getActivity(this, 1, intent, 1);
n.setLatestEventInfo(this, contentTitle, contentText, contentIntent);
}
从我的代码来看,
- 它没有显示在栏的顶部。
- 有没有什么好的解决办法可以上传一下。
请帮助我..
提前致谢。
有没有
My requirement is need to display notification,when upload is available.Each & every time go to new Activity, It check Upload is available.(Upload mean : IF there any changes happened in android db, then it indicate need to upload to actual sql server db).
See my code :
uploadSize = new UploadActivity().getUploadTable();
if(uploadSize > 0){
Button button = (Button) findViewById(R.id.u);
button.setBackgroundColor(Color.RED);
long whenTo = System.currentTimeMillis();
Notification n = new Notification(R.drawable.icon, "", whenTo);
n.tickerText = "TV Spored ++";
String contentTitle = "I am expanded title";
String contentText = "I am expanded text";
Intent intent = new Intent(this, NotificationReceiver.class);
// Put additional stuff into the created intent
PendingIntent contentIntent = PendingIntent.getActivity(this, 1, intent, 1);
n.setLatestEventInfo(this, contentTitle, contentText, contentIntent);
}
From the my code ,
- it didn't show the on the top of the bar.
- Is there any good solution is available for upload.
Please help me..
Thanks in advance.
Is there any
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显示通知调用此方法
To show Notification Call this method
您需要使用 NotificationManager。
您可以将此作为指南:创建状态栏通知
You'll need to use the NotificationManager.
You can use this as a guide: Creating Status Bar Notifications