如何将推送通知发送到android中的其他设备?

时间:2012-06-19 09:43:34

标签: android android-notifications android-notification-bar

使用此代码,我可以向自己的设备发送通知。

           Intent intent = new Intent(getApplicationContext(), ContactDonor.class);
            PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
            //display text
            String body = "Please Click on this to accept!";
            String title = bloodgroup+" Required";
            Notification n = new Notification(R.drawable.ic_launcher, body , System.currentTimeMillis());
            n.setLatestEventInfo(getApplicationContext(), title, body, pi);
            n.defaults = Notification.DEFAULT_ALL;
            nm.notify(uniqueID, n);
            finish();

但是现在我有一个屏幕,其中显示的人的详细信息如下:  名称: ...  电子邮件:...... ,并且有一个消息框和一个请求按钮,点击该按钮,他应该收到一条包含该特定消息的通知。怎么能做这个特别的事情?

1 个答案:

答案 0 :(得分:1)

使用PUSH notifications无法实现。 PUSH notificationserver-client通知server通知client server方发生的事件时,{{1}}非常有用。

您尝试间接实现的是服务器 - 客户端架构,您的设备将充当服务器。如果您将当前架构模制到服务器 - 客户端,您将能够向其他设备发送通知。在这种情况下,您也不需要PUSH通知,它将是一个简单的服务器 - 客户端通信。

有关PUSH的更多信息,请参阅:http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html#c2dm_sendmessage

您也可以发送短信,但这不能解决您的问题。据我所知,没有其他解决方案可以申请发送通知。

相关问题