求助:在短信的数据库里添加一条短信未读,怎么实现推送?

winjave 2013-03-04 04:13:00
  /**将发送的短信插入数据库**/  
ContentValues values = new ContentValues();
//发送时间
values.put("date", System.currentTimeMillis());
//阅读状态 0未读,1已读
values.put("read", 0);
//1为收 2为发
values.put("type", 1);
//送达号码
values.put("address", num);
//送达内容
values.put("body", text);
//插入短信库
context.getContentResolver().insert(Uri.parse("content://sms"),values);


在系统短信数据库里插入一条短信如何像新收到短信一样的有推送呢?
...全文
266 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
winjave 2013-03-05
  • 打赏
  • 举报
回复
好吧,自己写了个仿系统短信的推送,不完美
private void notification() {

		NotificationManager nm = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);

		Notification n = new Notification();

		// 设置显示在手机最上边的状态栏的图标
		n.icon = R.drawable.stat_notify_sms;
		// 当当前的notification被放到状态栏上的时候,提示内容
		n.tickerText = num + ":" + text;
		n.flags = Notification.FLAG_AUTO_CANCEL;

		

		Intent i = new Intent();
                //直接启动系统短信
		i.setComponent(new ComponentName("com.android.mms",
				"com.android.mms.ui.ConversationList"));
		i.setAction(Intent.ACTION_VIEW);

		PendingIntent p = PendingIntent.getActivity(context, 0, i,
				PendingIntent.FLAG_ONE_SHOT);
		n.setLatestEventInfo(context, num, text, p);
		nm.notify(1, n);

	}
winjave 2013-03-04
  • 打赏
  • 举报
回复
具体如何做?
j_f0001 2013-03-04
  • 打赏
  • 举报
回复
发一个通知呀,notion通知

80,362

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧