如何将数据推送到设备?

发布于 2024-11-27 06:22:57 字数 153 浏览 1 评论 0原文

我需要一种方法将数据从网络服务器推送到我的设备,如何实现这一点?我希望有一个指南来帮助我。我一直被 C2DM 困住了,这对我来说实在是太难以处理了。这些指南只是逐行列出代码,并没有解释它们的作用,这很糟糕。如果您能给我链接到一个可以教如何将数据推送到 Android 设备的指南,我会很高兴。

I need a way to push data to my device from my web server, how can I accomplish this? And I would love a guide to help me. I've been stuck on C2DM forever and its just too much for me to handle. The guides are just all list lines after lines of code and don't explain what they do, which sucks. I'd love if you could link me to a guide that can teaches how to push data to the android device.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

倾听心声的旋律 2024-12-04 06:22:57

我同意没有太多关于 CD2M 的文档。对我来说,最好的文档是 Google 示例。您可以抓住它们并按照代码来了解其工作原理。示例如下此处此处

  • 对于客户端(Android 应用程序),您有 3 个类来完成繁重的工作。您可以找到它们 在这里。使用它们,将这些类复制到您的项目中,然后您可以子类化 C2DMBaseReceiver 以提供您自己的实现(当您收到消息时会收到回调,错误时会收到回调,等等)。请记住在您的清单中注册这些内容,查看这些示例中的清单以了解如何操作。
  • 服务器端要容易得多。基本上,您首先从 Google 获取身份验证令牌,然后开始发送 HTTP 请求,这些请求是您的客户端将收到的消息。
  • 如果您计划使用 App Engine,那么您可以在这两个示例中找到如何实现服务器的示例。
  • 如果您计划使用 .NET 作为服务器,请查看 C2DM Sharp
  • 否则,我确信您会找到一些已经实现的库或一些有关如何设置服务器的示例。

I agree that there isn't too much documentation about CD2M. For me, the best docs are the Google examples. You can grab them and follow the code to understand how this works. Examples are here and here.

  • For the client side (the Android app) you have 3 classes that do the heavy work. You can find them here. Use them, copy those classes to your project and then you can subclass C2DMBaseReceiver to provide your own implementation (you get a callback when you receive a message, a callback for an error, and so on). Remember to register these things in your Manifest, look at the Manifest in those examples to know how to do it.
  • The server side is a lot easier. Basically you first get an auth token from Google, and then you start sending HTTP requests that are the messages that your client will receive.
  • If you are planning on using App Engine, then you can find examples of how to implement the server in both examples.
  • If you are planning on using .NET for the server, then take a look at C2DM Sharp.
  • Else I'm sure you will find some already implemented library or some examples on how to setup the server.
是伱的 2024-12-04 06:22:57

阅读这篇博文。它引用了许多可能性,并且可能正是您正在寻找的。 http://tokudu.com/2010/how-to-实现-push-notifications-for-android/

Read this blog post. It references many possibilities and is probably just what you are looking for. http://tokudu.com/2010/how-to-implement-push-notifications-for-android/

北城半夏 2024-12-04 06:22:57

在 .NET 3.5 或更高版本中使用 Windows Communication Foundation (WCF)。

Use Windows Communication Foundation (WCF) in .NET 3.5 or greater.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文