2

我正在开发 android 中的推送通知 GCM。我完成了基本功能意味着我正在发送一条短信并在 android 设备上将其作为通知接收。现在我想发送声音和图像文件,这将是我在 android 上的通知。有什么办法可以做到,因为 GCM 允许大小为 4kb 的消息,而且我没有看到任何将图像或声音作为通知发送的示例。任何帮助或链接或教程将不胜感激。

4

1 回答 1

9

You're right about the size limit. It is 4kb and cannot be any larger. If you need to send an image / sound or other binary data, send custom json with the message that points to a URL that houses the binary data (say http://myserver.com/mysoundfile.ext).

Your custom GCMIntentService can parse the data and download the file through an AsyncTask. If the file size is large use the DownloadManager service.

于 2013-04-13T11:40:26.457 回答