• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76<html>
77<head>
78
79
80
81<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
82
83<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
84<title>Sender | Android Developers</title>
85
86<!-- STYLESHEETS -->
87<link rel="stylesheet"
88href="//fonts.googleapis.com/css?family=Roboto:regular,medium,thin,italic,mediumitalic,bold" title="roboto">
89<link href="/assets/css/default.css" rel="stylesheet" type="text/css">
90
91
92
93<!-- JAVASCRIPT -->
94<script src="//www.google.com/jsapi" type="text/javascript"></script>
95<script src="/assets/js/android_3p-bundle.js" type="text/javascript"></script>
96<script type="text/javascript">
97  var toRoot = "/";
98  var devsite = false;
99</script>
100<script src="/assets/js/docs.js" type="text/javascript"></script>
101
102<script type="text/javascript">
103  var _gaq = _gaq || [];
104  _gaq.push(['_setAccount', 'UA-5831155-1']);
105  _gaq.push(['_trackPageview']);
106
107  (function() {
108    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
109    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
110    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
111  })();
112</script>
113</head>
114<body class="gc-documentation google
115  develop" itemscope itemtype="http://schema.org/Article">
116  <div id="doc-api-level" class="" style="display:none"></div>
117  <a name="top"></a>
118
119<a name="top"></a>
120
121    <!-- Header -->
122    <div id="header">
123        <div class="wrap" id="header-wrap">
124          <div class="col-3 logo">
125          <a href="/index.html">
126            <img src="/assets/images/dac_logo.png" width="123" height="25" alt="Android Developers" />
127          </a>
128          <div class="btn-quicknav" id="btn-quicknav">
129          	<a href="#" class="arrow-inactive">Quicknav</a>
130			      <a href="#" class="arrow-active">Quicknav</a>
131          </div>
132          </div>
133            <ul class="nav-x col-9">
134                <li class="design">
135                  <a href="/design/index.html"
136                  zh-tw-lang="設計"
137                  zh-cn-lang="设计"
138                  ru-lang="Проектирование"
139                  ko-lang="디자인"
140                  ja-lang="設計"
141                  es-lang="Diseñar"
142                  >Design</a></li>
143                <li class="develop"><a href="/develop/index.html"
144                  zh-tw-lang="開發"
145                  zh-cn-lang="开发"
146                  ru-lang="Разработка"
147                  ko-lang="개발"
148                  ja-lang="開発"
149                  es-lang="Desarrollar"
150                  >Develop</a></li>
151                <li class="distribute last"><a href="/distribute/index.html"
152                  zh-tw-lang="發佈"
153                  zh-cn-lang="分发"
154                  ru-lang="Распространение"
155                  ko-lang="배포"
156                  ja-lang="配布"
157                  es-lang="Distribuir"
158                  >Distribute</a></li>
159            </ul>
160
161            <!-- New Search -->
162            <div class="menu-container">
163            <div class="moremenu">
164    <div id="more-btn"></div>
165  </div>
166  <div class="morehover" id="moremenu">
167    <div class="top"></div>
168    <div class="mid">
169      <div class="header">Links</div>
170      <ul>
171        <li><a href="https://play.google.com/apps/publish/">Google Play Developer Console</a></li>
172        <li><a href="http://android-developers.blogspot.com/">Android Developers Blog</a></li>
173        <li><a href="/about/index.html">About Android</a></li>
174      </ul>
175      <div class="header">Android Sites</div>
176      <ul>
177        <li><a href="http://www.android.com">Android.com</a></li>
178        <li class="active"><a>Android Developers</a></li>
179        <li><a href="http://source.android.com">Android Open Source Project</a></li>
180      </ul>
181
182
183
184        <div class="header">Language</div>
185          <div id="language" class="locales">
186            <select name="language" onChange="changeLangPref(this.value, true)">
187                <option value="en">English</option>
188                <option value="es">Español</option>
189                <option value="ja">日本語</option>
190                <option value="ko">한국어</option>
191                <option value="ru">Русский</option>
192                <option value="zh-cn">中文 (中国)</option>
193                <option value="zh-tw">中文 (台灣)</option>
194            </select>
195          </div>
196        <script type="text/javascript">
197          <!--
198          loadLangPref();
199            //-->
200        </script>
201
202
203
204
205      <br class="clearfix" />
206    </div>
207    <div class="bottom"></div>
208  </div>
209  <div class="search" id="search-container">
210    <div class="search-inner">
211      <div id="search-btn"></div>
212      <div class="left"></div>
213      <form onsubmit="return submit_search()">
214        <input id="search_autocomplete" type="text" value="" autocomplete="off" name="q"
215onfocus="search_focus_changed(this, true)" onblur="search_focus_changed(this, false)"
216onkeydown="return search_changed(event, true, '/')"
217onkeyup="return search_changed(event, false, '/')" />
218      </form>
219      <div class="right"></div>
220        <a class="close hide">close</a>
221        <div class="left"></div>
222        <div class="right"></div>
223    </div>
224  </div>
225
226  <div class="search_filtered_wrapper reference">
227    <div class="suggest-card reference no-display">
228      <ul class="search_filtered">
229      </ul>
230    </div>
231  </div>
232
233  <div class="search_filtered_wrapper docs">
234    <div class="suggest-card dummy no-display">&nbsp;</div>
235    <div class="suggest-card develop no-display">
236      <ul class="search_filtered">
237      </ul>
238      <div class="child-card guides no-display">
239      </div>
240      <div class="child-card training no-display">
241      </div>
242    </div>
243    <div class="suggest-card design no-display">
244      <ul class="search_filtered">
245      </ul>
246    </div>
247    <div class="suggest-card distribute no-display">
248      <ul class="search_filtered">
249      </ul>
250    </div>
251  </div>
252
253  </div>
254  <!-- /New Search>
255
256
257          <!-- Expanded quicknav -->
258           <div id="quicknav" class="col-9">
259                <ul>
260                    <li class="design">
261                      <ul>
262                        <li><a href="/design/index.html">Get Started</a></li>
263                        <li><a href="/design/style/index.html">Style</a></li>
264                        <li><a href="/design/patterns/index.html">Patterns</a></li>
265                        <li><a href="/design/building-blocks/index.html">Building Blocks</a></li>
266                        <li><a href="/design/downloads/index.html">Downloads</a></li>
267                        <li><a href="/design/videos/index.html">Videos</a></li>
268                      </ul>
269                    </li>
270                    <li class="develop">
271                      <ul>
272                        <li><a href="/training/index.html"
273                          zh-tw-lang="訓練課程"
274                          zh-cn-lang="培训"
275                          ru-lang="Курсы"
276                          ko-lang="교육"
277                          ja-lang="トレーニング"
278                          es-lang="Capacitación"
279                          >Training</a></li>
280                        <li><a href="/guide/components/index.html"
281                          zh-tw-lang="API 指南"
282                          zh-cn-lang="API 指南"
283                          ru-lang="Руководства по API"
284                          ko-lang="API 가이드"
285                          ja-lang="API ガイド"
286                          es-lang="Guías de la API"
287                          >API Guides</a></li>
288                        <li><a href="/reference/packages.html"
289                          zh-tw-lang="參考資源"
290                          zh-cn-lang="参考"
291                          ru-lang="Справочник"
292                          ko-lang="참조문서"
293                          ja-lang="リファレンス"
294                          es-lang="Referencia"
295                          >Reference</a></li>
296                        <li><a href="/tools/index.html"
297                          zh-tw-lang="相關工具"
298                          zh-cn-lang="工具"
299                          ru-lang="Инструменты"
300                          ko-lang="도구"
301                          ja-lang="ツール"
302                          es-lang="Herramientas"
303                          >Tools</a>
304                          <ul><li><a href="/sdk/index.html">Get the SDK</a></li></ul>
305                        </li>
306                        <li><a href="/google/index.html">Google Services</a>
307                        </li>
308                      </ul>
309                    </li>
310                    <li class="distribute last">
311                      <ul>
312                        <li><a href="/distribute/index.html">Google Play</a></li>
313                        <li><a href="/distribute/googleplay/publish/index.html">Publishing</a></li>
314                        <li><a href="/distribute/googleplay/promote/index.html">Promoting</a></li>
315                        <li><a href="/distribute/googleplay/quality/index.html">App Quality</a></li>
316                        <li><a href="/distribute/googleplay/spotlight/index.html">Spotlight</a></li>
317                        <li><a href="/distribute/open.html">Open Distribution</a></li>
318                      </ul>
319                    </li>
320                </ul>
321          </div>
322          <!-- /Expanded quicknav -->
323        </div>
324    </div>
325    <!-- /Header -->
326
327
328  <div id="searchResults" class="wrap" style="display:none;">
329          <h2 id="searchTitle">Results</h2>
330          <div id="leftSearchControl" class="search-control">Loading...</div>
331  </div>
332
333
334
335    <!-- Secondary x-nav -->
336    <div id="nav-x">
337        <div class="wrap">
338            <ul class="nav-x col-9 develop" style="width:100%">
339                <li class="training"><a href="/training/index.html"
340                  zh-tw-lang="訓練課程"
341                  zh-cn-lang="培训"
342                  ru-lang="Курсы"
343                  ko-lang="교육"
344                  ja-lang="トレーニング"
345                  es-lang="Capacitación"
346                  >Training</a></li>
347                <li class="guide"><a href="/guide/components/index.html"
348                  zh-tw-lang="API 指南"
349                  zh-cn-lang="API 指南"
350                  ru-lang="Руководства по API"
351                  ko-lang="API 가이드"
352                  ja-lang="API ガイド"
353                  es-lang="Guías de la API"
354                  >API Guides</a></li>
355                <li class="reference"><a href="/reference/packages.html"
356                  zh-tw-lang="參考資源"
357                  zh-cn-lang="参考"
358                  ru-lang="Справочник"
359                  ko-lang="참조문서"
360                  ja-lang="リファレンス"
361                  es-lang="Referencia"
362                  >Reference</a></li>
363                <li class="tools"><a href="/tools/index.html"
364                  zh-tw-lang="相關工具"
365                  zh-cn-lang="工具"
366                  ru-lang="Инструменты"
367                  ko-lang="도구"
368                  ja-lang="ツール"
369                  es-lang="Herramientas"
370                  >Tools</a></li>
371                <li class="google"><a href="/google/index.html"
372                  >Google Services</a>
373                </li>
374            </ul>
375        </div>
376
377    </div>
378    <!-- /Sendondary x-nav -->
379
380
381
382
383
384
385
386
387
388  <div class="wrap clearfix" id="body-content">
389    <div class="col-4" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
390      <div id="devdoc-nav" class="scroll-pane">
391<a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
392
393
394
395<ul id="nav">
396
397  <li class="nav-section">
398    <div class="nav-section-header empty"><a href="/google/index.html">
399          <span class="en">Overview</span>
400      </a></div>
401  </li>
402
403  <li class="nav-section">
404    <div class="nav-section-header empty"><a href="/google/play-services/games.html">
405          <span class="en">Games</span>
406      </a></div>
407  </li>
408  <li class="nav-section">
409    <div class="nav-section-header empty"><a href="/google/play-services/location.html">
410          <span class="en">Location</span>
411      </a></div>
412  </li>
413  <li class="nav-section">
414    <div class="nav-section-header empty"><a href="/google/play-services/plus.html">
415          <span class="en">Google+</span>
416                </a></div>
417  </li>
418  <li class="nav-section">
419    <div class="nav-section-header empty"><a href="/google/play-services/maps.html">
420          <span class="en">Google Maps</span>
421      </a></div>
422  </li>
423  <li class="nav-section">
424    <div class="nav-section-header empty"><a href="/google/play-services/auth.html">
425          <span class="en">Authorization</span>
426      </a></div>
427  </li>
428
429
430
431  <li class="nav-section">
432    <div class="nav-section-header"><a href="/google/play-services/index.html">
433      <span class="en">Google Play Services</span></a>
434    </div>
435    <ul>
436      <li><a href="/google/play-services/setup.html">
437          <span class="en">Setup</span></a>
438      </li>
439      <li id="gms-tree-list" class="nav-section">
440        <div class="nav-section-header">
441          <a href="/reference/gms-packages.html">
442            <span class="en">Reference</span>
443          </a>
444        <div>
445      </li>
446    </ul>
447  </li>
448
449
450  <li class="nav-section">
451    <div class="nav-section-header"><a href="/google/play/billing/index.html">
452      <span class="en">Google Play In-app Billing</span></a>
453    </div>
454    <ul>
455      <li><a href="/google/play/billing/billing_overview.html">
456              <span class="en">Overview</span></a>
457      </li>
458      <li class="nav-section"><div class="nav-section-header"><a href="/google/play/billing/api.html">
459              <span class="en">Version 3 API</span></a></div>
460              <ul>
461              <li><a href="/google/play/billing/billing_integrate.html">
462              <span class="en">Implementing the API</span></a></li>
463              <li><a href="/google/play/billing/billing_reference.html">
464              <span class="en">Reference</span></a></li>
465              </ul>
466      </li>
467      <li class="nav-section"><div class="nav-section-header"><a href="/google/play/billing/v2/api.html">
468              <span class="en">Version 2 API</span></a></div>
469              <ul>
470              <li><a href="/google/play/billing/v2/billing_integrate.html">
471              <span class="en">Implementing the API</span></a></li>
472              <li><a href="/google/play/billing/v2/billing_subscriptions.html">
473              <span class="en">Subscriptions</span></a></li>
474              <li><a href="/google/play/billing/v2/billing_reference.html">
475              <span class="en">Reference</span></a></li>
476              </ul>
477      </li>
478      <li><a href="/google/play/billing/billing_subscriptions.html">
479              <span class="en">Subscriptions</span></a>
480      </li>
481      <li><a href="/google/play/billing/billing_best_practices.html">
482              <span class="en">Security and Design</span></a>
483      </li>
484      <li><a href="/google/play/billing/billing_testing.html">
485              <span class="en">Testing In-app Billing</span></a>
486      </li>
487      <li><a href="/google/play/billing/billing_admin.html">
488              <span class="en">Administering In-app Billing</span></a>
489      </li>
490      <li><a href="/google/play/billing/versions.html">
491              <span class="en">Version Notes</span></a>
492      </li>
493    </ul>
494  </li>
495
496
497
498  <li class="nav-section">
499      <div class="nav-section-header"><a href="/google/gcm/index.html">
500        <span class="en">Google Cloud Messaging</span></a>
501      </div>
502      <ul>
503        <li><a href="/google/gcm/gs.html">
504            <span class="en">Getting Started</span></a>
505        </li>
506        <li><a href="/google/gcm/gcm.html">
507            <span class="en">Architectural Overview</span></a>
508        </li>
509        <li><a href="/google/gcm/demo.html">
510            <span class="en">Demo App Tutorial</span></a>
511        </li>
512        <li><a href="/google/gcm/adv.html">
513            <span class="en">Advanced Topics</span></a>
514        </li>
515        <li><a href="/google/gcm/c2dm.html">
516            <span class="en">Migration</span></a>
517        </li>
518        <li id="gcm-tree-list" class="nav-section">
519          <div class="nav-section-header">
520            <a href="/reference/gcm-packages.html">
521              <span class="en">Reference</span>
522            </a>
523          <div>
524        </li>
525      </ul>
526  </li>
527
528  <li class="nav-section">
529    <div class="nav-section-header"><a href="/google/play/dist.html">
530      <span class="en">Google Play Distribution</span></a>
531    </div>
532    <ul>
533      <li><a href="/google/play/filters.html">
534          <span class="en">Filters on Google Play</span></a>
535      </li>
536
537      <li><a href="/google/play/publishing/multiple-apks.html">
538          <span class="en">Multiple APK Support</span></a>
539      </li>
540      <li><a href="/google/play/expansion-files.html">
541          <span class="en">APK Expansion Files</span></a>
542      </li>
543      <li class="nav-section">
544        <div class="nav-section-header"><a href="/google/play/licensing/index.html">
545          <span class="en">Application Licensing</span></a>
546        </div>
547        <ul>
548          <li><a href="/google/play/licensing/overview.html">
549              <span class="en">Licensing Overview</span></a>
550          </li>
551          <li><a href="/google/play/licensing/setting-up.html">
552              <span class="en">Setting Up for Licensing</span></a>
553          </li>
554          <li><a href="/google/play/licensing/adding-licensing.html">
555              <span class="en">Adding Licensing to Your App</span></a>
556          </li>
557          <li><a href="/google/play/licensing/licensing-reference.html">
558              <span class="en">Licensing Reference</span></a>
559          </li>
560        </ul>
561      </li>
562
563  <li class="nav-section">
564    <div class="nav-section-header"><a href="/google/backup/index.html">
565      Android Backup Service</a>
566    </div>
567    <ul>
568      <li><a href="/google/backup/signup.html">
569          Register</a>
570      </li>
571    </ul>
572  </li>
573
574  </ul>
575
576</li>
577
578
579
580</ul>
581
582<script type="text/javascript">
583<!--
584    buildToggleLists();
585    changeNavLang(getLangPref());
586//-->
587</script>
588
589
590
591
592      </div>
593      <script type="text/javascript">
594       showGoogleRefTree();
595
596      </script>
597    </div> <!-- end side-nav -->
598    <script>
599      $(document).ready(function() {
600        scrollIntoView("devdoc-nav");
601        });
602    </script>
603
604
605
606
607
608
609<div class="col-12"  id="doc-col">
610
611<div id="api-info-block">
612
613
614
615
616
617
618
619
620
621
622
623<div class="sum-details-links">
624
625Summary:
626
627
628
629
630
631  <a href="#constants">Constants</a>
632
633
634
635
636  &#124; <a href="#lfields">Fields</a>
637
638
639
640
641  &#124; <a href="#pubctors">Ctors</a>
642
643
644
645
646  &#124; <a href="#pubmethods">Methods</a>
647
648
649
650  &#124; <a href="#promethods">Protected Methods</a>
651
652
653
654  &#124; <a href="#inhmethods">Inherited Methods</a>
655
656&#124; <a href="#" onclick="return toggleAllClassInherited()" id="toggleAllClassInherited">[Expand All]</a>
657
658</div><!-- end sum-details-links -->
659<div class="api-level">
660
661
662
663
664</div>
665</div><!-- end api-info-block -->
666
667
668<!-- ======== START OF CLASS DATA ======== -->
669
670<div id="jd-header">
671    public
672
673
674
675    class
676<h1 itemprop="name">Sender</h1>
677
678
679
680
681    extends Object<br/>
682
683
684
685
686
687
688
689
690
691</div><!-- end header -->
692
693<div id="naMessage"></div>
694
695<div id="jd-content" class="api apilevel-">
696<table class="jd-inheritance-table">
697
698
699    <tr>
700
701        <td colspan="2" class="jd-inheritance-class-cell">java.lang.Object</td>
702    </tr>
703
704
705    <tr>
706
707            <td class="jd-inheritance-space">&nbsp;&nbsp;&nbsp;&#x21b3;</td>
708
709        <td colspan="1" class="jd-inheritance-class-cell">com.google.android.gcm.server.Sender</td>
710    </tr>
711
712
713</table>
714
715
716
717
718
719
720
721<div class="jd-descr">
722
723
724<h2>Class Overview</h2>
725<p itemprop="articleBody">Helper class to send messages to the GCM service using an API Key.
726</p>
727
728
729
730
731
732</div><!-- jd-descr -->
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749<div class="jd-descr">
750
751
752<h2>Summary</h2>
753
754
755
756
757
758
759
760
761
762
763
764
765
766<!-- =========== ENUM CONSTANT SUMMARY =========== -->
767<table id="constants" class="jd-sumtable"><tr><th colspan="12">Constants</th></tr>
768
769
770
771    <tr class="alt-color api apilevel-" >
772        <td class="jd-typecol">int</td>
773        <td class="jd-linkcol"><a href="/reference/com/google/android/gcm/server/Sender.html#BACKOFF_INITIAL_DELAY">BACKOFF_INITIAL_DELAY</a></td>
774        <td class="jd-descrcol" width="100%">Initial delay before first retry, without jitter.</td>
775    </tr>
776
777
778    <tr class=" api apilevel-" >
779        <td class="jd-typecol">int</td>
780        <td class="jd-linkcol"><a href="/reference/com/google/android/gcm/server/Sender.html#MAX_BACKOFF_DELAY">MAX_BACKOFF_DELAY</a></td>
781        <td class="jd-descrcol" width="100%">Maximum delay before a retry.</td>
782    </tr>
783
784
785    <tr class="alt-color api apilevel-" >
786        <td class="jd-typecol">String</td>
787        <td class="jd-linkcol"><a href="/reference/com/google/android/gcm/server/Sender.html#UTF8">UTF8</a></td>
788        <td class="jd-descrcol" width="100%"></td>
789    </tr>
790
791
792
793</table>
794
795
796
797
798
799
800
801<!-- =========== FIELD SUMMARY =========== -->
802<table id="lfields" class="jd-sumtable"><tr><th colspan="12">Fields</th></tr>
803
804
805
806      <tr class="alt-color api apilevel-" >
807          <td class="jd-typecol"><nobr>
808          protected
809          static
810          final
811          Logger</nobr></td>
812          <td class="jd-linkcol"><a href="/reference/com/google/android/gcm/server/Sender.html#logger">logger</a></td>
813          <td class="jd-descrcol" width="100%"></td>
814      </tr>
815
816
817      <tr class=" api apilevel-" >
818          <td class="jd-typecol"><nobr>
819          protected
820
821          final
822          Random</nobr></td>
823          <td class="jd-linkcol"><a href="/reference/com/google/android/gcm/server/Sender.html#random">random</a></td>
824          <td class="jd-descrcol" width="100%"></td>
825      </tr>
826
827
828
829</table>
830
831
832
833
834
835
836
837<!-- ======== CONSTRUCTOR SUMMARY ======== -->
838<table id="pubctors" class="jd-sumtable"><tr><th colspan="12">Public Constructors</th></tr>
839
840
841
842
843    <tr class="alt-color api apilevel-" >
844        <td class="jd-typecol"><nobr>
845
846
847
848
849
850            </nobr>
851        </td>
852        <td class="jd-linkcol" width="100%"><nobr>
853        <span class="sympad"><a href="/reference/com/google/android/gcm/server/Sender.html#Sender(java.lang.String)">Sender</a></span>(String key)</nobr>
854
855        <div class="jd-descrdiv">Default constructor.</div>
856
857  </td></tr>
858
859
860
861</table>
862
863
864
865
866
867
868<!-- ========== METHOD SUMMARY =========== -->
869<table id="pubmethods" class="jd-sumtable"><tr><th colspan="12">Public Methods</th></tr>
870
871
872
873
874    <tr class="alt-color api apilevel-" >
875        <td class="jd-typecol"><nobr>
876
877
878
879
880
881            <a href="/reference/com/google/android/gcm/server/MulticastResult.html">MulticastResult</a></nobr>
882        </td>
883        <td class="jd-linkcol" width="100%"><nobr>
884        <span class="sympad"><a href="/reference/com/google/android/gcm/server/Sender.html#send(com.google.android.gcm.server.Message, java.util.List<java.lang.String>, int)">send</a></span>(<a href="/reference/com/google/android/gcm/server/Message.html">Message</a> message, List&lt;String&gt; regIds, int retries)</nobr>
885
886        <div class="jd-descrdiv">Sends a message to many devices, retrying in case of unavailability.</div>
887
888  </td></tr>
889
890
891
892    <tr class=" api apilevel-" >
893        <td class="jd-typecol"><nobr>
894
895
896
897
898
899            <a href="/reference/com/google/android/gcm/server/Result.html">Result</a></nobr>
900        </td>
901        <td class="jd-linkcol" width="100%"><nobr>
902        <span class="sympad"><a href="/reference/com/google/android/gcm/server/Sender.html#send(com.google.android.gcm.server.Message, java.lang.String, int)">send</a></span>(<a href="/reference/com/google/android/gcm/server/Message.html">Message</a> message, String registrationId, int retries)</nobr>
903
904        <div class="jd-descrdiv">Sends a message to one device, retrying in case of unavailability.</div>
905
906  </td></tr>
907
908
909
910    <tr class="alt-color api apilevel-" >
911        <td class="jd-typecol"><nobr>
912
913
914
915
916
917            <a href="/reference/com/google/android/gcm/server/Result.html">Result</a></nobr>
918        </td>
919        <td class="jd-linkcol" width="100%"><nobr>
920        <span class="sympad"><a href="/reference/com/google/android/gcm/server/Sender.html#sendNoRetry(com.google.android.gcm.server.Message, java.lang.String)">sendNoRetry</a></span>(<a href="/reference/com/google/android/gcm/server/Message.html">Message</a> message, String registrationId)</nobr>
921
922        <div class="jd-descrdiv">Sends a message without retrying in case of service unavailability.</div>
923
924  </td></tr>
925
926
927
928    <tr class=" api apilevel-" >
929        <td class="jd-typecol"><nobr>
930
931
932
933
934
935            <a href="/reference/com/google/android/gcm/server/MulticastResult.html">MulticastResult</a></nobr>
936        </td>
937        <td class="jd-linkcol" width="100%"><nobr>
938        <span class="sympad"><a href="/reference/com/google/android/gcm/server/Sender.html#sendNoRetry(com.google.android.gcm.server.Message, java.util.List<java.lang.String>)">sendNoRetry</a></span>(<a href="/reference/com/google/android/gcm/server/Message.html">Message</a> message, List&lt;String&gt; registrationIds)</nobr>
939
940        <div class="jd-descrdiv">Sends a message without retrying in case of service unavailability.</div>
941
942  </td></tr>
943
944
945
946</table>
947
948
949
950
951<!-- ========== METHOD SUMMARY =========== -->
952<table id="promethods" class="jd-sumtable"><tr><th colspan="12">Protected Methods</th></tr>
953
954
955
956
957    <tr class="alt-color api apilevel-" >
958        <td class="jd-typecol"><nobr>
959
960
961
962            static
963
964            void</nobr>
965        </td>
966        <td class="jd-linkcol" width="100%"><nobr>
967        <span class="sympad"><a href="/reference/com/google/android/gcm/server/Sender.html#addParameter(java.lang.StringBuilder, java.lang.String, java.lang.String)">addParameter</a></span>(StringBuilder body, String name, String value)</nobr>
968
969        <div class="jd-descrdiv">Adds a new parameter to the HTTP POST body.</div>
970
971  </td></tr>
972
973
974
975    <tr class=" api apilevel-" >
976        <td class="jd-typecol"><nobr>
977
978
979
980
981
982            HttpURLConnection</nobr>
983        </td>
984        <td class="jd-linkcol" width="100%"><nobr>
985        <span class="sympad"><a href="/reference/com/google/android/gcm/server/Sender.html#getConnection(java.lang.String)">getConnection</a></span>(String url)</nobr>
986
987        <div class="jd-descrdiv">Gets an <code><a href="/reference/java/net/HttpURLConnection.html">HttpURLConnection</a></code> given an URL.</div>
988
989  </td></tr>
990
991
992
993    <tr class="alt-color api apilevel-" >
994        <td class="jd-typecol"><nobr>
995
996
997
998            static
999
1000            String</nobr>
1001        </td>
1002        <td class="jd-linkcol" width="100%"><nobr>
1003        <span class="sympad"><a href="/reference/com/google/android/gcm/server/Sender.html#getString(java.io.InputStream)">getString</a></span>(InputStream stream)</nobr>
1004
1005        <div class="jd-descrdiv">Convenience method to convert an InputStream to a String.</div>
1006
1007  </td></tr>
1008
1009
1010
1011    <tr class=" api apilevel-" >
1012        <td class="jd-typecol"><nobr>
1013
1014
1015
1016            static
1017
1018            StringBuilder</nobr>
1019        </td>
1020        <td class="jd-linkcol" width="100%"><nobr>
1021        <span class="sympad"><a href="/reference/com/google/android/gcm/server/Sender.html#newBody(java.lang.String, java.lang.String)">newBody</a></span>(String name, String value)</nobr>
1022
1023        <div class="jd-descrdiv">Creates a <code><a href="/reference/java/lang/StringBuilder.html">StringBuilder</a></code> to be used as the body of an HTTP POST.</div>
1024
1025  </td></tr>
1026
1027
1028
1029    <tr class="alt-color api apilevel-" >
1030        <td class="jd-typecol"><nobr>
1031
1032
1033            final
1034            static
1035
1036            Map&lt;String,&nbsp;String&gt;</nobr>
1037        </td>
1038        <td class="jd-linkcol" width="100%"><nobr>
1039        <span class="sympad"><a href="/reference/com/google/android/gcm/server/Sender.html#newKeyValues(java.lang.String, java.lang.String)">newKeyValues</a></span>(String key, String value)</nobr>
1040
1041        <div class="jd-descrdiv">Creates a map with just one key-value pair.</div>
1042
1043  </td></tr>
1044
1045
1046
1047    <tr class=" api apilevel-" >
1048        <td class="jd-typecol"><nobr>
1049
1050
1051
1052
1053
1054            HttpURLConnection</nobr>
1055        </td>
1056        <td class="jd-linkcol" width="100%"><nobr>
1057        <span class="sympad"><a href="/reference/com/google/android/gcm/server/Sender.html#post(java.lang.String, java.lang.String, java.lang.String)">post</a></span>(String url, String contentType, String body)</nobr>
1058
1059        <div class="jd-descrdiv">Makes an HTTP POST request to a given endpoint.</div>
1060
1061  </td></tr>
1062
1063
1064
1065    <tr class="alt-color api apilevel-" >
1066        <td class="jd-typecol"><nobr>
1067
1068
1069
1070
1071
1072            HttpURLConnection</nobr>
1073        </td>
1074        <td class="jd-linkcol" width="100%"><nobr>
1075        <span class="sympad"><a href="/reference/com/google/android/gcm/server/Sender.html#post(java.lang.String, java.lang.String)">post</a></span>(String url, String body)</nobr>
1076
1077        <div class="jd-descrdiv">Make an HTTP post to a given URL.</div>
1078
1079  </td></tr>
1080
1081
1082
1083</table>
1084
1085
1086
1087
1088
1089<!-- ========== METHOD SUMMARY =========== -->
1090<table id="inhmethods" class="jd-sumtable"><tr><th>
1091  <a href="#" class="toggle-all" onclick="return toggleAllInherited(this, null)">[Expand]</a>
1092  <div style="clear:left;">Inherited Methods</div></th></tr>
1093
1094
1095<tr class="api apilevel-" >
1096<td colspan="12">
1097  <a href="#" onclick="return toggleInherited(this, null)" id="inherited-methods-java.lang.Object" class="jd-expando-trigger closed"
1098          ><img id="inherited-methods-java.lang.Object-trigger"
1099          src="/assets/images/triangle-closed.png"
1100          class="jd-expando-trigger-img" /></a>
1101From class
1102
1103  java.lang.Object
1104
1105<div id="inherited-methods-java.lang.Object">
1106  <div id="inherited-methods-java.lang.Object-list"
1107        class="jd-inheritedlinks">
1108  </div>
1109  <div id="inherited-methods-java.lang.Object-summary" style="display: none;">
1110    <table class="jd-sumtable-expando">
1111
1112
1113
1114
1115    <tr class="alt-color api apilevel-" >
1116        <td class="jd-typecol"><nobr>
1117
1118
1119
1120
1121
1122            Object</nobr>
1123        </td>
1124        <td class="jd-linkcol" width="100%"><nobr>
1125        <span class="sympad">clone</span>()</nobr>
1126
1127  </td></tr>
1128
1129
1130
1131    <tr class=" api apilevel-" >
1132        <td class="jd-typecol"><nobr>
1133
1134
1135
1136
1137
1138            boolean</nobr>
1139        </td>
1140        <td class="jd-linkcol" width="100%"><nobr>
1141        <span class="sympad">equals</span>(Object arg0)</nobr>
1142
1143  </td></tr>
1144
1145
1146
1147    <tr class="alt-color api apilevel-" >
1148        <td class="jd-typecol"><nobr>
1149
1150
1151
1152
1153
1154            void</nobr>
1155        </td>
1156        <td class="jd-linkcol" width="100%"><nobr>
1157        <span class="sympad">finalize</span>()</nobr>
1158
1159  </td></tr>
1160
1161
1162
1163    <tr class=" api apilevel-" >
1164        <td class="jd-typecol"><nobr>
1165
1166
1167            final
1168
1169
1170            Class&lt;?&gt;</nobr>
1171        </td>
1172        <td class="jd-linkcol" width="100%"><nobr>
1173        <span class="sympad">getClass</span>()</nobr>
1174
1175  </td></tr>
1176
1177
1178
1179    <tr class="alt-color api apilevel-" >
1180        <td class="jd-typecol"><nobr>
1181
1182
1183
1184
1185
1186            int</nobr>
1187        </td>
1188        <td class="jd-linkcol" width="100%"><nobr>
1189        <span class="sympad">hashCode</span>()</nobr>
1190
1191  </td></tr>
1192
1193
1194
1195    <tr class=" api apilevel-" >
1196        <td class="jd-typecol"><nobr>
1197
1198
1199            final
1200
1201
1202            void</nobr>
1203        </td>
1204        <td class="jd-linkcol" width="100%"><nobr>
1205        <span class="sympad">notify</span>()</nobr>
1206
1207  </td></tr>
1208
1209
1210
1211    <tr class="alt-color api apilevel-" >
1212        <td class="jd-typecol"><nobr>
1213
1214
1215            final
1216
1217
1218            void</nobr>
1219        </td>
1220        <td class="jd-linkcol" width="100%"><nobr>
1221        <span class="sympad">notifyAll</span>()</nobr>
1222
1223  </td></tr>
1224
1225
1226
1227    <tr class=" api apilevel-" >
1228        <td class="jd-typecol"><nobr>
1229
1230
1231
1232
1233
1234            String</nobr>
1235        </td>
1236        <td class="jd-linkcol" width="100%"><nobr>
1237        <span class="sympad">toString</span>()</nobr>
1238
1239  </td></tr>
1240
1241
1242
1243    <tr class="alt-color api apilevel-" >
1244        <td class="jd-typecol"><nobr>
1245
1246
1247            final
1248
1249
1250            void</nobr>
1251        </td>
1252        <td class="jd-linkcol" width="100%"><nobr>
1253        <span class="sympad">wait</span>()</nobr>
1254
1255  </td></tr>
1256
1257
1258
1259    <tr class=" api apilevel-" >
1260        <td class="jd-typecol"><nobr>
1261
1262
1263            final
1264
1265
1266            void</nobr>
1267        </td>
1268        <td class="jd-linkcol" width="100%"><nobr>
1269        <span class="sympad">wait</span>(long arg0, int arg1)</nobr>
1270
1271  </td></tr>
1272
1273
1274
1275    <tr class="alt-color api apilevel-" >
1276        <td class="jd-typecol"><nobr>
1277
1278
1279            final
1280
1281
1282            void</nobr>
1283        </td>
1284        <td class="jd-linkcol" width="100%"><nobr>
1285        <span class="sympad">wait</span>(long arg0)</nobr>
1286
1287  </td></tr>
1288
1289
1290</table>
1291  </div>
1292</div>
1293</td></tr>
1294
1295
1296</table>
1297
1298
1299</div><!-- jd-descr (summary) -->
1300
1301<!-- Details -->
1302
1303
1304
1305
1306
1307
1308
1309
1310<!-- XML Attributes -->
1311
1312
1313<!-- Enum Values -->
1314
1315
1316<!-- Constants -->
1317
1318
1319<!-- ========= ENUM CONSTANTS DETAIL ======== -->
1320<h2>Constants</h2>
1321
1322
1323
1324
1325<A NAME="BACKOFF_INITIAL_DELAY"></A>
1326
1327<div class="jd-details api apilevel-">
1328    <h4 class="jd-details-title">
1329      <span class="normal">
1330        protected
1331        static
1332        final
1333        int
1334      </span>
1335        BACKOFF_INITIAL_DELAY
1336    </h4>
1337      <div class="api-level">
1338
1339
1340
1341
1342      </div>
1343    <div class="jd-details-descr">
1344
1345  <div class="jd-tagdata jd-tagdescr"><p>Initial delay before first retry, without jitter.
1346</p></div>
1347
1348
1349        <div class="jd-tagdata">
1350        <span class="jd-tagtitle">Constant Value: </span>
1351        <span>
1352
1353                1000
1354                (0x000003e8)
1355
1356        </span>
1357        </div>
1358
1359    </div>
1360</div>
1361
1362
1363
1364<A NAME="MAX_BACKOFF_DELAY"></A>
1365
1366<div class="jd-details api apilevel-">
1367    <h4 class="jd-details-title">
1368      <span class="normal">
1369        protected
1370        static
1371        final
1372        int
1373      </span>
1374        MAX_BACKOFF_DELAY
1375    </h4>
1376      <div class="api-level">
1377
1378
1379
1380
1381      </div>
1382    <div class="jd-details-descr">
1383
1384  <div class="jd-tagdata jd-tagdescr"><p>Maximum delay before a retry.
1385</p></div>
1386
1387
1388        <div class="jd-tagdata">
1389        <span class="jd-tagtitle">Constant Value: </span>
1390        <span>
1391
1392                1024000
1393                (0x000fa000)
1394
1395        </span>
1396        </div>
1397
1398    </div>
1399</div>
1400
1401
1402
1403<A NAME="UTF8"></A>
1404
1405<div class="jd-details api apilevel-">
1406    <h4 class="jd-details-title">
1407      <span class="normal">
1408        protected
1409        static
1410        final
1411        String
1412      </span>
1413        UTF8
1414    </h4>
1415      <div class="api-level">
1416
1417
1418
1419
1420      </div>
1421    <div class="jd-details-descr">
1422
1423  <div class="jd-tagdata jd-tagdescr"><p></p></div>
1424
1425
1426        <div class="jd-tagdata">
1427        <span class="jd-tagtitle">Constant Value: </span>
1428        <span>
1429
1430                "UTF-8"
1431
1432        </span>
1433        </div>
1434
1435    </div>
1436</div>
1437
1438
1439
1440
1441<!-- Fields -->
1442
1443
1444<!-- ========= FIELD DETAIL ======== -->
1445<h2>Fields</h2>
1446
1447
1448
1449
1450<A NAME="logger"></A>
1451
1452<div class="jd-details api apilevel-">
1453    <h4 class="jd-details-title">
1454      <span class="normal">
1455        protected
1456        static
1457        final
1458        Logger
1459      </span>
1460        logger
1461    </h4>
1462      <div class="api-level">
1463
1464
1465
1466
1467      </div>
1468    <div class="jd-details-descr">
1469
1470  <div class="jd-tagdata jd-tagdescr"><p></p></div>
1471
1472
1473    </div>
1474</div>
1475
1476
1477
1478<A NAME="random"></A>
1479
1480<div class="jd-details api apilevel-">
1481    <h4 class="jd-details-title">
1482      <span class="normal">
1483        protected
1484
1485        final
1486        Random
1487      </span>
1488        random
1489    </h4>
1490      <div class="api-level">
1491
1492
1493
1494
1495      </div>
1496    <div class="jd-details-descr">
1497
1498  <div class="jd-tagdata jd-tagdescr"><p></p></div>
1499
1500
1501    </div>
1502</div>
1503
1504
1505
1506
1507<!-- Public ctors -->
1508
1509
1510<!-- ========= CONSTRUCTOR DETAIL ======== -->
1511<h2>Public Constructors</h2>
1512
1513
1514
1515<A NAME="Sender(java.lang.String)"></A>
1516
1517<div class="jd-details api apilevel-">
1518    <h4 class="jd-details-title">
1519      <span class="normal">
1520        public
1521
1522
1523
1524
1525
1526      </span>
1527      <span class="sympad">Sender</span>
1528      <span class="normal">(String key)</span>
1529    </h4>
1530      <div class="api-level">
1531        <div></div>
1532
1533
1534
1535      </div>
1536    <div class="jd-details-descr">
1537
1538  <div class="jd-tagdata jd-tagdescr"><p>Default constructor.</p></div>
1539  <div class="jd-tagdata">
1540      <h5 class="jd-tagtitle">Parameters</h5>
1541      <table class="jd-tagtable">
1542        <tr>
1543          <th>key</td>
1544          <td>API key obtained through the Google API Console.
1545</td>
1546        </tr>
1547      </table>
1548  </div>
1549
1550    </div>
1551</div>
1552
1553
1554
1555
1556
1557<!-- ========= CONSTRUCTOR DETAIL ======== -->
1558<!-- Protected ctors -->
1559
1560
1561
1562<!-- ========= METHOD DETAIL ======== -->
1563<!-- Public methdos -->
1564
1565<h2>Public Methods</h2>
1566
1567
1568
1569<A NAME="send(com.google.android.gcm.server.Message, java.util.List<java.lang.String>, int)"></A>
1570
1571<div class="jd-details api apilevel-">
1572    <h4 class="jd-details-title">
1573      <span class="normal">
1574        public
1575
1576
1577
1578
1579        <a href="/reference/com/google/android/gcm/server/MulticastResult.html">MulticastResult</a>
1580      </span>
1581      <span class="sympad">send</span>
1582      <span class="normal">(<a href="/reference/com/google/android/gcm/server/Message.html">Message</a> message, List&lt;String&gt; regIds, int retries)</span>
1583    </h4>
1584      <div class="api-level">
1585        <div></div>
1586
1587
1588
1589      </div>
1590    <div class="jd-details-descr">
1591
1592  <div class="jd-tagdata jd-tagdescr"><p>Sends a message to many devices, retrying in case of unavailability.
1593
1594 <p>
1595 <strong>Note: </strong> this method uses exponential back-off to retry in
1596 case of service unavailability and hence could block the calling thread
1597 for many seconds.</p></div>
1598  <div class="jd-tagdata">
1599      <h5 class="jd-tagtitle">Parameters</h5>
1600      <table class="jd-tagtable">
1601        <tr>
1602          <th>message</td>
1603          <td>message to be sent.</td>
1604        </tr>
1605        <tr>
1606          <th>regIds</td>
1607          <td>registration id of the devices that will receive
1608        the message.</td>
1609        </tr>
1610        <tr>
1611          <th>retries</td>
1612          <td>number of retries in case of service unavailability errors.</td>
1613        </tr>
1614      </table>
1615  </div>
1616  <div class="jd-tagdata">
1617      <h5 class="jd-tagtitle">Returns</h5>
1618      <ul class="nolist"><li>combined result of all requests made.</li></ul>
1619  </div>
1620  <div class="jd-tagdata">
1621      <h5 class="jd-tagtitle">Throws</h5>
1622      <table class="jd-tagtable">
1623        <tr>
1624            <th>IllegalArgumentException</td>
1625            <td>if registrationIds is null or
1626         empty.</td>
1627        </tr>
1628        <tr>
1629            <th><a href="/reference/com/google/android/gcm/server/InvalidRequestException.html">InvalidRequestException</a></td>
1630            <td>if GCM didn't returned a 200 or 503 status.</td>
1631        </tr>
1632        <tr>
1633            <th>IOException</td>
1634            <td>if message could not be sent.
1635</td>
1636        </tr>
1637      </table>
1638  </div>
1639
1640    </div>
1641</div>
1642
1643
1644<A NAME="send(com.google.android.gcm.server.Message, java.lang.String, int)"></A>
1645
1646<div class="jd-details api apilevel-">
1647    <h4 class="jd-details-title">
1648      <span class="normal">
1649        public
1650
1651
1652
1653
1654        <a href="/reference/com/google/android/gcm/server/Result.html">Result</a>
1655      </span>
1656      <span class="sympad">send</span>
1657      <span class="normal">(<a href="/reference/com/google/android/gcm/server/Message.html">Message</a> message, String registrationId, int retries)</span>
1658    </h4>
1659      <div class="api-level">
1660        <div></div>
1661
1662
1663
1664      </div>
1665    <div class="jd-details-descr">
1666
1667  <div class="jd-tagdata jd-tagdescr"><p>Sends a message to one device, retrying in case of unavailability.
1668
1669 <p>
1670 <strong>Note: </strong> this method uses exponential back-off to retry in
1671 case of service unavailability and hence could block the calling thread
1672 for many seconds.</p></div>
1673  <div class="jd-tagdata">
1674      <h5 class="jd-tagtitle">Parameters</h5>
1675      <table class="jd-tagtable">
1676        <tr>
1677          <th>message</td>
1678          <td>message to be sent, including the device's registration id.</td>
1679        </tr>
1680        <tr>
1681          <th>registrationId</td>
1682          <td>device where the message will be sent.</td>
1683        </tr>
1684        <tr>
1685          <th>retries</td>
1686          <td>number of retries in case of service unavailability errors.</td>
1687        </tr>
1688      </table>
1689  </div>
1690  <div class="jd-tagdata">
1691      <h5 class="jd-tagtitle">Returns</h5>
1692      <ul class="nolist"><li>result of the request (see its javadoc for more details).</li></ul>
1693  </div>
1694  <div class="jd-tagdata">
1695      <h5 class="jd-tagtitle">Throws</h5>
1696      <table class="jd-tagtable">
1697        <tr>
1698            <th>IllegalArgumentException</td>
1699            <td>if registrationId is null.</td>
1700        </tr>
1701        <tr>
1702            <th><a href="/reference/com/google/android/gcm/server/InvalidRequestException.html">InvalidRequestException</a></td>
1703            <td>if GCM didn't returned a 200 or 5xx status.</td>
1704        </tr>
1705        <tr>
1706            <th>IOException</td>
1707            <td>if message could not be sent.
1708</td>
1709        </tr>
1710      </table>
1711  </div>
1712
1713    </div>
1714</div>
1715
1716
1717<A NAME="sendNoRetry(com.google.android.gcm.server.Message, java.lang.String)"></A>
1718
1719<div class="jd-details api apilevel-">
1720    <h4 class="jd-details-title">
1721      <span class="normal">
1722        public
1723
1724
1725
1726
1727        <a href="/reference/com/google/android/gcm/server/Result.html">Result</a>
1728      </span>
1729      <span class="sympad">sendNoRetry</span>
1730      <span class="normal">(<a href="/reference/com/google/android/gcm/server/Message.html">Message</a> message, String registrationId)</span>
1731    </h4>
1732      <div class="api-level">
1733        <div></div>
1734
1735
1736
1737      </div>
1738    <div class="jd-details-descr">
1739
1740  <div class="jd-tagdata jd-tagdescr"><p>Sends a message without retrying in case of service unavailability. See
1741 <code><a href="/reference/com/google/android/gcm/server/Sender.html#send(com.google.android.gcm.server.Message, java.lang.String, int)">send(Message, String, int)</a></code> for more info.</p></div>
1742  <div class="jd-tagdata">
1743      <h5 class="jd-tagtitle">Returns</h5>
1744      <ul class="nolist"><li>result of the post, or null if the GCM service was
1745         unavailable or any network exception caused the request to fail.</li></ul>
1746  </div>
1747  <div class="jd-tagdata">
1748      <h5 class="jd-tagtitle">Throws</h5>
1749      <table class="jd-tagtable">
1750        <tr>
1751            <th><a href="/reference/com/google/android/gcm/server/InvalidRequestException.html">InvalidRequestException</a></td>
1752            <td>if GCM didn't returned a 200 or 5xx status.</td>
1753        </tr>
1754        <tr>
1755            <th>IllegalArgumentException</td>
1756            <td>if registrationId is null.
1757</td>
1758        </tr>
1759        <tr>
1760            <th>IOException</td>
1761            <td></td>
1762        </tr>
1763      </table>
1764  </div>
1765
1766    </div>
1767</div>
1768
1769
1770<A NAME="sendNoRetry(com.google.android.gcm.server.Message, java.util.List<java.lang.String>)"></A>
1771
1772<div class="jd-details api apilevel-">
1773    <h4 class="jd-details-title">
1774      <span class="normal">
1775        public
1776
1777
1778
1779
1780        <a href="/reference/com/google/android/gcm/server/MulticastResult.html">MulticastResult</a>
1781      </span>
1782      <span class="sympad">sendNoRetry</span>
1783      <span class="normal">(<a href="/reference/com/google/android/gcm/server/Message.html">Message</a> message, List&lt;String&gt; registrationIds)</span>
1784    </h4>
1785      <div class="api-level">
1786        <div></div>
1787
1788
1789
1790      </div>
1791    <div class="jd-details-descr">
1792
1793  <div class="jd-tagdata jd-tagdescr"><p>Sends a message without retrying in case of service unavailability. See
1794 <code><a href="/reference/com/google/android/gcm/server/Sender.html#send(com.google.android.gcm.server.Message, java.util.List<java.lang.String>, int)">send(Message, List, int)</a></code> for more info.</p></div>
1795  <div class="jd-tagdata">
1796      <h5 class="jd-tagtitle">Returns</h5>
1797      <ul class="nolist"><li>multicast results if the message was sent successfully,
1798         null if it failed but could be retried.</li></ul>
1799  </div>
1800  <div class="jd-tagdata">
1801      <h5 class="jd-tagtitle">Throws</h5>
1802      <table class="jd-tagtable">
1803        <tr>
1804            <th>IllegalArgumentException</td>
1805            <td>if registrationIds is null or
1806         empty.</td>
1807        </tr>
1808        <tr>
1809            <th><a href="/reference/com/google/android/gcm/server/InvalidRequestException.html">InvalidRequestException</a></td>
1810            <td>if GCM didn't returned a 200 status.</td>
1811        </tr>
1812        <tr>
1813            <th>IOException</td>
1814            <td>if there was a JSON parsing error
1815</td>
1816        </tr>
1817      </table>
1818  </div>
1819
1820    </div>
1821</div>
1822
1823
1824
1825
1826
1827<!-- ========= METHOD DETAIL ======== -->
1828
1829<h2>Protected Methods</h2>
1830
1831
1832
1833<A NAME="addParameter(java.lang.StringBuilder, java.lang.String, java.lang.String)"></A>
1834
1835<div class="jd-details api apilevel-">
1836    <h4 class="jd-details-title">
1837      <span class="normal">
1838        protected
1839        static
1840
1841
1842
1843        void
1844      </span>
1845      <span class="sympad">addParameter</span>
1846      <span class="normal">(StringBuilder body, String name, String value)</span>
1847    </h4>
1848      <div class="api-level">
1849        <div></div>
1850
1851
1852
1853      </div>
1854    <div class="jd-details-descr">
1855
1856  <div class="jd-tagdata jd-tagdescr"><p>Adds a new parameter to the HTTP POST body.</p></div>
1857  <div class="jd-tagdata">
1858      <h5 class="jd-tagtitle">Parameters</h5>
1859      <table class="jd-tagtable">
1860        <tr>
1861          <th>body</td>
1862          <td>HTTP POST body.</td>
1863        </tr>
1864        <tr>
1865          <th>name</td>
1866          <td>parameter's name.</td>
1867        </tr>
1868        <tr>
1869          <th>value</td>
1870          <td>parameter's value.
1871</td>
1872        </tr>
1873      </table>
1874  </div>
1875
1876    </div>
1877</div>
1878
1879
1880<A NAME="getConnection(java.lang.String)"></A>
1881
1882<div class="jd-details api apilevel-">
1883    <h4 class="jd-details-title">
1884      <span class="normal">
1885        protected
1886
1887
1888
1889
1890        HttpURLConnection
1891      </span>
1892      <span class="sympad">getConnection</span>
1893      <span class="normal">(String url)</span>
1894    </h4>
1895      <div class="api-level">
1896        <div></div>
1897
1898
1899
1900      </div>
1901    <div class="jd-details-descr">
1902
1903  <div class="jd-tagdata jd-tagdescr"><p>Gets an <code><a href="/reference/java/net/HttpURLConnection.html">HttpURLConnection</a></code> given an URL.
1904</p></div>
1905  <div class="jd-tagdata">
1906      <h5 class="jd-tagtitle">Throws</h5>
1907      <table class="jd-tagtable">
1908        <tr>
1909            <th>IOException</td>
1910            <td></td>
1911        </tr>
1912      </table>
1913  </div>
1914
1915    </div>
1916</div>
1917
1918
1919<A NAME="getString(java.io.InputStream)"></A>
1920
1921<div class="jd-details api apilevel-">
1922    <h4 class="jd-details-title">
1923      <span class="normal">
1924        protected
1925        static
1926
1927
1928
1929        String
1930      </span>
1931      <span class="sympad">getString</span>
1932      <span class="normal">(InputStream stream)</span>
1933    </h4>
1934      <div class="api-level">
1935        <div></div>
1936
1937
1938
1939      </div>
1940    <div class="jd-details-descr">
1941
1942  <div class="jd-tagdata jd-tagdescr"><p>Convenience method to convert an InputStream to a String.
1943 <p>
1944 If the stream ends in a newline character, it will be stripped.
1945 <p>
1946 If the stream is null, returns an empty string.
1947</p></div>
1948  <div class="jd-tagdata">
1949      <h5 class="jd-tagtitle">Throws</h5>
1950      <table class="jd-tagtable">
1951        <tr>
1952            <th>IOException</td>
1953            <td></td>
1954        </tr>
1955      </table>
1956  </div>
1957
1958    </div>
1959</div>
1960
1961
1962<A NAME="newBody(java.lang.String, java.lang.String)"></A>
1963
1964<div class="jd-details api apilevel-">
1965    <h4 class="jd-details-title">
1966      <span class="normal">
1967        protected
1968        static
1969
1970
1971
1972        StringBuilder
1973      </span>
1974      <span class="sympad">newBody</span>
1975      <span class="normal">(String name, String value)</span>
1976    </h4>
1977      <div class="api-level">
1978        <div></div>
1979
1980
1981
1982      </div>
1983    <div class="jd-details-descr">
1984
1985  <div class="jd-tagdata jd-tagdescr"><p>Creates a <code><a href="/reference/java/lang/StringBuilder.html">StringBuilder</a></code> to be used as the body of an HTTP POST.</p></div>
1986  <div class="jd-tagdata">
1987      <h5 class="jd-tagtitle">Parameters</h5>
1988      <table class="jd-tagtable">
1989        <tr>
1990          <th>name</td>
1991          <td>initial parameter for the POST.</td>
1992        </tr>
1993        <tr>
1994          <th>value</td>
1995          <td>initial value for that parameter.</td>
1996        </tr>
1997      </table>
1998  </div>
1999  <div class="jd-tagdata">
2000      <h5 class="jd-tagtitle">Returns</h5>
2001      <ul class="nolist"><li>StringBuilder to be used an HTTP POST body.
2002</li></ul>
2003  </div>
2004
2005    </div>
2006</div>
2007
2008
2009<A NAME="newKeyValues(java.lang.String, java.lang.String)"></A>
2010
2011<div class="jd-details api apilevel-">
2012    <h4 class="jd-details-title">
2013      <span class="normal">
2014        protected
2015        static
2016        final
2017
2018
2019        Map&lt;String,&nbsp;String&gt;
2020      </span>
2021      <span class="sympad">newKeyValues</span>
2022      <span class="normal">(String key, String value)</span>
2023    </h4>
2024      <div class="api-level">
2025        <div></div>
2026
2027
2028
2029      </div>
2030    <div class="jd-details-descr">
2031
2032  <div class="jd-tagdata jd-tagdescr"><p>Creates a map with just one key-value pair.
2033</p></div>
2034
2035    </div>
2036</div>
2037
2038
2039<A NAME="post(java.lang.String, java.lang.String, java.lang.String)"></A>
2040
2041<div class="jd-details api apilevel-">
2042    <h4 class="jd-details-title">
2043      <span class="normal">
2044        protected
2045
2046
2047
2048
2049        HttpURLConnection
2050      </span>
2051      <span class="sympad">post</span>
2052      <span class="normal">(String url, String contentType, String body)</span>
2053    </h4>
2054      <div class="api-level">
2055        <div></div>
2056
2057
2058
2059      </div>
2060    <div class="jd-details-descr">
2061
2062  <div class="jd-tagdata jd-tagdescr"><p>Makes an HTTP POST request to a given endpoint.
2063
2064 <p>
2065 <strong>Note: </strong> the returned connected should not be disconnected,
2066 otherwise it would kill persistent connections made using Keep-Alive.</p></div>
2067  <div class="jd-tagdata">
2068      <h5 class="jd-tagtitle">Parameters</h5>
2069      <table class="jd-tagtable">
2070        <tr>
2071          <th>url</td>
2072          <td>endpoint to post the request.</td>
2073        </tr>
2074        <tr>
2075          <th>contentType</td>
2076          <td>type of request.</td>
2077        </tr>
2078        <tr>
2079          <th>body</td>
2080          <td>body of the request.</td>
2081        </tr>
2082      </table>
2083  </div>
2084  <div class="jd-tagdata">
2085      <h5 class="jd-tagtitle">Returns</h5>
2086      <ul class="nolist"><li>the underlying connection.</li></ul>
2087  </div>
2088  <div class="jd-tagdata">
2089      <h5 class="jd-tagtitle">Throws</h5>
2090      <table class="jd-tagtable">
2091        <tr>
2092            <th>IOException</td>
2093            <td>propagated from underlying methods.
2094</td>
2095        </tr>
2096      </table>
2097  </div>
2098
2099    </div>
2100</div>
2101
2102
2103<A NAME="post(java.lang.String, java.lang.String)"></A>
2104
2105<div class="jd-details api apilevel-">
2106    <h4 class="jd-details-title">
2107      <span class="normal">
2108        protected
2109
2110
2111
2112
2113        HttpURLConnection
2114      </span>
2115      <span class="sympad">post</span>
2116      <span class="normal">(String url, String body)</span>
2117    </h4>
2118      <div class="api-level">
2119        <div></div>
2120
2121
2122
2123      </div>
2124    <div class="jd-details-descr">
2125
2126  <div class="jd-tagdata jd-tagdescr"><p>Make an HTTP post to a given URL.</p></div>
2127  <div class="jd-tagdata">
2128      <h5 class="jd-tagtitle">Returns</h5>
2129      <ul class="nolist"><li>HTTP response.
2130</li></ul>
2131  </div>
2132  <div class="jd-tagdata">
2133      <h5 class="jd-tagtitle">Throws</h5>
2134      <table class="jd-tagtable">
2135        <tr>
2136            <th>IOException</td>
2137            <td></td>
2138        </tr>
2139      </table>
2140  </div>
2141
2142    </div>
2143</div>
2144
2145
2146
2147
2148
2149<!-- ========= END OF CLASS DATA ========= -->
2150<A NAME="navbar_top"></A>
2151
2152<div id="footer" class="wrap" >
2153
2154
2155  <div id="copyright">
2156
2157  Except as noted, this content is licensed under <a
2158  href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>.
2159  For details and restrictions, see the <a href="/license.html">
2160  Content License</a>.
2161  </div>
2162  <div id="build_info">
2163
2164<script src="/timestamp.js" type="text/javascript"></script>
2165<script>document.write(BUILD_TIMESTAMP)</script>
2166
2167  </div>
2168
2169
2170  <div id="footerlinks">
2171
2172  <p>
2173    <a href="/about/index.html">About Android</a>&nbsp;&nbsp;|&nbsp;
2174    <a href="/legal.html">Legal</a>&nbsp;&nbsp;|&nbsp;
2175    <a href="/support.html">Support</a>
2176  </p>
2177  </div>
2178
2179</div> <!-- end footer -->
2180</div> <!-- jd-content -->
2181
2182</div><!-- end doc-content -->
2183
2184</div> <!-- end body-content -->
2185
2186
2187
2188
2189
2190
2191</body>
2192</html>
2193