android - 将新消息放入收件箱,然后设备对其进行管理

标签 android android-intent android-notifications android-broadcast

我有一个 android 程序,我在 web 上从外部服务器的数据库接收一条消息,然后我将消息放入 SMS 收件箱。

现在我像这样使用系统通知:

通知 Intent :

    ctx = context ;
    notificationManager = (NotificationManager) ctx
            .getSystemService(Context.NOTIFICATION_SERVICE);
    syncNotification = new Notification();
    notificationIntent = new Intent(Intent.ACTION_MAIN,null);
    notificationIntent.setComponent(new    ComponentName("com.android.mms","com.android.mms.ui.ConversationList"));
    notificationIntent.addFlags(Notification.FLAG_AUTO_CANCEL);
    contentIntent = PendingIntent.getActivity(ctx, 0,
            notificationIntent, 0);

通知创建:

syncNotification.icon = android.R.drawable.stat_notify_chat;
syncNotification.tickerText = ctx.getText(R.string.new_message);
syncNotification.when = System.currentTimeMillis();
syncNotification.setLatestEventInfo(ctx, ctx.getText(R.string.new_message),  ctx.getText(R.string.check_your_inbox),contentIntent);
notificationManager.notify(5, syncNotification);

然后播放短信铃声:

Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(ctx, notification);
r.play();

收到消息并将其放入收件箱后,显示了通知,但是当我点击它时没有任何反应。

有没有办法在将消息插入收件箱后,设备显示默认通知并进行管理?

最佳答案

在 android api 14 及更高版本中这是不可能的,因为谷歌阻止了。

关于android - 将新消息放入收件箱,然后设备对其进行管理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18149564/

相关文章:

java - CalDAV 实现

Android 在菜单项选择上启动 Activity

Android putSerializable 与 putString

android - 简单的方式在 Activity 和 Intent 之间传递arraylist

android - 如何检测通知id是否存在?

android - 确定触摸通知图标的作用

android - 大通知图标旁边的灰色圆圈?

android - 高度 ListView - 所有行可见

android - 使用服务创建系统警报窗口是否发送顶级 Activity onPause

android - paypal android sdk 货币错误错误