blob: 5224e15d23256381e5f65763dceeea380b6bc54b [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 16 14:12:10 PDT 2012 -->
<TITLE>
Sender
</TITLE>
<META NAME="date" CONTENT="2012-07-16">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../default.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Sender";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../com/google/android/gcm/server/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../com/google/android/gcm/server/Result.html" title="class in com.google.android.gcm.server"><B>PREV CLASS</B></A>&nbsp;
&nbsp;NEXT CLASS</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?com/google/android/gcm/server/Sender.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="Sender.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
com.google.android.gcm.server</FONT>
<BR>
Class Sender</H2>
<PRE>
java.lang.Object
<IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>com.google.android.gcm.server.Sender</B>
</PRE>
<HR>
<DL>
<DT><PRE>public class <B>Sender</B><DT>extends java.lang.Object</DL>
</PRE>
<P>
Helper class to send messages to the GCM service using an API Key.
<P>
<P>
<HR>
<P>
<!-- =========== FIELD SUMMARY =========== -->
<A NAME="field_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Field Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#BACKOFF_INITIAL_DELAY">BACKOFF_INITIAL_DELAY</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Initial delay before first retry, without jitter.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;java.util.logging.Logger</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#logger">logger</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#MAX_BACKOFF_DELAY">MAX_BACKOFF_DELAY</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Maximum delay before a retry.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;java.util.Random</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#random">random</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected static&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#UTF8">UTF8</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
</TABLE>
&nbsp;
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#Sender(java.lang.String)">Sender</A></B>(java.lang.String&nbsp;key)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default constructor.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected static&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#addParameter(java.lang.StringBuilder, java.lang.String, java.lang.String)">addParameter</A></B>(java.lang.StringBuilder&nbsp;body,
java.lang.String&nbsp;name,
java.lang.String&nbsp;value)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Adds a new parameter to the HTTP POST body.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;java.net.HttpURLConnection</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#getConnection(java.lang.String)">getConnection</A></B>(java.lang.String&nbsp;url)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets an <CODE>HttpURLConnection</CODE> given an URL.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected static&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#getString(java.io.InputStream)">getString</A></B>(java.io.InputStream&nbsp;stream)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Convenience method to convert an InputStream to a String.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected static&nbsp;java.lang.StringBuilder</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#newBody(java.lang.String, java.lang.String)">newBody</A></B>(java.lang.String&nbsp;name,
java.lang.String&nbsp;value)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates a <CODE>StringBuilder</CODE> to be used as the body of an HTTP POST.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected static&nbsp;java.util.Map&lt;java.lang.String,java.lang.String&gt;</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#newKeyValues(java.lang.String, java.lang.String)">newKeyValues</A></B>(java.lang.String&nbsp;key,
java.lang.String&nbsp;value)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates a map with just one key-value pair.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;java.net.HttpURLConnection</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#post(java.lang.String, java.lang.String)">post</A></B>(java.lang.String&nbsp;url,
java.lang.String&nbsp;body)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Make an HTTP post to a given URL.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;java.net.HttpURLConnection</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#post(java.lang.String, java.lang.String, java.lang.String)">post</A></B>(java.lang.String&nbsp;url,
java.lang.String&nbsp;contentType,
java.lang.String&nbsp;body)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../../com/google/android/gcm/server/MulticastResult.html" title="class in com.google.android.gcm.server">MulticastResult</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#send(com.google.android.gcm.server.Message, java.util.List, int)">send</A></B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A>&nbsp;message,
java.util.List&lt;java.lang.String&gt;&nbsp;regIds,
int&nbsp;retries)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sends a message to many devices, retrying in case of unavailability.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../../com/google/android/gcm/server/Result.html" title="class in com.google.android.gcm.server">Result</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#send(com.google.android.gcm.server.Message, java.lang.String, int)">send</A></B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A>&nbsp;message,
java.lang.String&nbsp;registrationId,
int&nbsp;retries)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sends a message to one device, retrying in case of unavailability.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../../com/google/android/gcm/server/MulticastResult.html" title="class in com.google.android.gcm.server">MulticastResult</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#sendNoRetry(com.google.android.gcm.server.Message, java.util.List)">sendNoRetry</A></B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A>&nbsp;message,
java.util.List&lt;java.lang.String&gt;&nbsp;registrationIds)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sends a message without retrying in case of service unavailability.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../../com/google/android/gcm/server/Result.html" title="class in com.google.android.gcm.server">Result</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#sendNoRetry(com.google.android.gcm.server.Message, java.lang.String)">sendNoRetry</A></B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A>&nbsp;message,
java.lang.String&nbsp;registrationId)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sends a message without retrying in case of service unavailability.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ============ FIELD DETAIL =========== -->
<A NAME="field_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Field Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="UTF8"><!-- --></A><H3>
UTF8</H3>
<PRE>
protected static final java.lang.String <B>UTF8</B></PRE>
<DL>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#com.google.android.gcm.server.Sender.UTF8">Constant Field Values</A></DL>
</DL>
<HR>
<A NAME="BACKOFF_INITIAL_DELAY"><!-- --></A><H3>
BACKOFF_INITIAL_DELAY</H3>
<PRE>
protected static final int <B>BACKOFF_INITIAL_DELAY</B></PRE>
<DL>
<DD>Initial delay before first retry, without jitter.
<P>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#com.google.android.gcm.server.Sender.BACKOFF_INITIAL_DELAY">Constant Field Values</A></DL>
</DL>
<HR>
<A NAME="MAX_BACKOFF_DELAY"><!-- --></A><H3>
MAX_BACKOFF_DELAY</H3>
<PRE>
protected static final int <B>MAX_BACKOFF_DELAY</B></PRE>
<DL>
<DD>Maximum delay before a retry.
<P>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#com.google.android.gcm.server.Sender.MAX_BACKOFF_DELAY">Constant Field Values</A></DL>
</DL>
<HR>
<A NAME="random"><!-- --></A><H3>
random</H3>
<PRE>
protected final java.util.Random <B>random</B></PRE>
<DL>
<DL>
</DL>
</DL>
<HR>
<A NAME="logger"><!-- --></A><H3>
logger</H3>
<PRE>
protected final java.util.logging.Logger <B>logger</B></PRE>
<DL>
<DL>
</DL>
</DL>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="Sender(java.lang.String)"><!-- --></A><H3>
Sender</H3>
<PRE>
public <B>Sender</B>(java.lang.String&nbsp;key)</PRE>
<DL>
<DD>Default constructor.
<P>
<DL>
<DT><B>Parameters:</B><DD><CODE>key</CODE> - API key obtained through the Google API Console.</DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="send(com.google.android.gcm.server.Message, java.lang.String, int)"><!-- --></A><H3>
send</H3>
<PRE>
public <A HREF="../../../../../com/google/android/gcm/server/Result.html" title="class in com.google.android.gcm.server">Result</A> <B>send</B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A>&nbsp;message,
java.lang.String&nbsp;registrationId,
int&nbsp;retries)
throws java.io.IOException</PRE>
<DL>
<DD>Sends a message to one device, retrying in case of unavailability.
<p>
<strong>Note: </strong> this method uses exponential back-off to retry in
case of service unavailability and hence could block the calling thread
for many seconds.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>message</CODE> - message to be sent, including the device's registration id.<DD><CODE>registrationId</CODE> - device where the message will be sent.<DD><CODE>retries</CODE> - number of retries in case of service unavailability errors.
<DT><B>Returns:</B><DD>result of the request (see its javadoc for more details)
<DT><B>Throws:</B>
<DD><CODE>java.lang.IllegalArgumentException</CODE> - if registrationId is null.
<DD><CODE><A HREF="../../../../../com/google/android/gcm/server/InvalidRequestException.html" title="class in com.google.android.gcm.server">InvalidRequestException</A></CODE> - if GCM didn't returned a 200 or 503 status.
<DD><CODE>java.io.IOException</CODE> - if message could not be sent.</DL>
</DD>
</DL>
<HR>
<A NAME="sendNoRetry(com.google.android.gcm.server.Message, java.lang.String)"><!-- --></A><H3>
sendNoRetry</H3>
<PRE>
public <A HREF="../../../../../com/google/android/gcm/server/Result.html" title="class in com.google.android.gcm.server">Result</A> <B>sendNoRetry</B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A>&nbsp;message,
java.lang.String&nbsp;registrationId)
throws java.io.IOException</PRE>
<DL>
<DD>Sends a message without retrying in case of service unavailability. See
<A HREF="../../../../../com/google/android/gcm/server/Sender.html#send(com.google.android.gcm.server.Message, java.lang.String, int)"><CODE>send(Message, String, int)</CODE></A> for more info.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>result of the post, or null if the GCM service was
unavailable.
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../../../../com/google/android/gcm/server/InvalidRequestException.html" title="class in com.google.android.gcm.server">InvalidRequestException</A></CODE> - if GCM didn't returned a 200 or 503 status.
<DD><CODE>java.lang.IllegalArgumentException</CODE> - if registrationId is null.
<DD><CODE>java.io.IOException</CODE></DL>
</DD>
</DL>
<HR>
<A NAME="send(com.google.android.gcm.server.Message, java.util.List, int)"><!-- --></A><H3>
send</H3>
<PRE>
public <A HREF="../../../../../com/google/android/gcm/server/MulticastResult.html" title="class in com.google.android.gcm.server">MulticastResult</A> <B>send</B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A>&nbsp;message,
java.util.List&lt;java.lang.String&gt;&nbsp;regIds,
int&nbsp;retries)
throws java.io.IOException</PRE>
<DL>
<DD>Sends a message to many devices, retrying in case of unavailability.
<p>
<strong>Note: </strong> this method uses exponential back-off to retry in
case of service unavailability and hence could block the calling thread
for many seconds.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>message</CODE> - message to be sent.<DD><CODE>regIds</CODE> - registration id of the devices that will receive
the message.<DD><CODE>retries</CODE> - number of retries in case of service unavailability errors.
<DT><B>Returns:</B><DD>combined result of all requests made.
<DT><B>Throws:</B>
<DD><CODE>java.lang.IllegalArgumentException</CODE> - if registrationIds is null or
empty.
<DD><CODE><A HREF="../../../../../com/google/android/gcm/server/InvalidRequestException.html" title="class in com.google.android.gcm.server">InvalidRequestException</A></CODE> - if GCM didn't returned a 200 or 503 status.
<DD><CODE>java.io.IOException</CODE> - if message could not be sent.</DL>
</DD>
</DL>
<HR>
<A NAME="sendNoRetry(com.google.android.gcm.server.Message, java.util.List)"><!-- --></A><H3>
sendNoRetry</H3>
<PRE>
public <A HREF="../../../../../com/google/android/gcm/server/MulticastResult.html" title="class in com.google.android.gcm.server">MulticastResult</A> <B>sendNoRetry</B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A>&nbsp;message,
java.util.List&lt;java.lang.String&gt;&nbsp;registrationIds)
throws java.io.IOException</PRE>
<DL>
<DD>Sends a message without retrying in case of service unavailability. See
<A HREF="../../../../../com/google/android/gcm/server/Sender.html#send(com.google.android.gcm.server.Message, java.util.List, int)"><CODE>send(Message, List, int)</CODE></A> for more info.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>true if the message was sent successfully,
false if it failed but could be retried.
<DT><B>Throws:</B>
<DD><CODE>java.lang.IllegalArgumentException</CODE> - if registrationIds is null or
empty.
<DD><CODE><A HREF="../../../../../com/google/android/gcm/server/InvalidRequestException.html" title="class in com.google.android.gcm.server">InvalidRequestException</A></CODE> - if GCM didn't returned a 200 status.
<DD><CODE>java.io.IOException</CODE> - if message could not be sent or received.</DL>
</DD>
</DL>
<HR>
<A NAME="post(java.lang.String, java.lang.String)"><!-- --></A><H3>
post</H3>
<PRE>
protected java.net.HttpURLConnection <B>post</B>(java.lang.String&nbsp;url,
java.lang.String&nbsp;body)
throws java.io.IOException</PRE>
<DL>
<DD>Make an HTTP post to a given URL.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>HTTP response.
<DT><B>Throws:</B>
<DD><CODE>java.io.IOException</CODE></DL>
</DD>
</DL>
<HR>
<A NAME="post(java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>
post</H3>
<PRE>
protected java.net.HttpURLConnection <B>post</B>(java.lang.String&nbsp;url,
java.lang.String&nbsp;contentType,
java.lang.String&nbsp;body)
throws java.io.IOException</PRE>
<DL>
<DD><DL>
<DT><B>Throws:</B>
<DD><CODE>java.io.IOException</CODE></DL>
</DD>
</DL>
<HR>
<A NAME="newKeyValues(java.lang.String, java.lang.String)"><!-- --></A><H3>
newKeyValues</H3>
<PRE>
protected static final java.util.Map&lt;java.lang.String,java.lang.String&gt; <B>newKeyValues</B>(java.lang.String&nbsp;key,
java.lang.String&nbsp;value)</PRE>
<DL>
<DD>Creates a map with just one key-value pair.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="newBody(java.lang.String, java.lang.String)"><!-- --></A><H3>
newBody</H3>
<PRE>
protected static java.lang.StringBuilder <B>newBody</B>(java.lang.String&nbsp;name,
java.lang.String&nbsp;value)</PRE>
<DL>
<DD>Creates a <CODE>StringBuilder</CODE> to be used as the body of an HTTP POST.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - initial parameter for the POST.<DD><CODE>value</CODE> - initial value for that parameter.
<DT><B>Returns:</B><DD>StringBuilder to be used an HTTP POST body.</DL>
</DD>
</DL>
<HR>
<A NAME="addParameter(java.lang.StringBuilder, java.lang.String, java.lang.String)"><!-- --></A><H3>
addParameter</H3>
<PRE>
protected static void <B>addParameter</B>(java.lang.StringBuilder&nbsp;body,
java.lang.String&nbsp;name,
java.lang.String&nbsp;value)</PRE>
<DL>
<DD>Adds a new parameter to the HTTP POST body.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>body</CODE> - HTTP POST body<DD><CODE>name</CODE> - parameter's name<DD><CODE>value</CODE> - parameter's value</DL>
</DD>
</DL>
<HR>
<A NAME="getConnection(java.lang.String)"><!-- --></A><H3>
getConnection</H3>
<PRE>
protected java.net.HttpURLConnection <B>getConnection</B>(java.lang.String&nbsp;url)
throws java.io.IOException</PRE>
<DL>
<DD>Gets an <CODE>HttpURLConnection</CODE> given an URL.
<P>
<DD><DL>
<DT><B>Throws:</B>
<DD><CODE>java.io.IOException</CODE></DL>
</DD>
</DL>
<HR>
<A NAME="getString(java.io.InputStream)"><!-- --></A><H3>
getString</H3>
<PRE>
protected static java.lang.String <B>getString</B>(java.io.InputStream&nbsp;stream)
throws java.io.IOException</PRE>
<DL>
<DD>Convenience method to convert an InputStream to a String.
<p>
If the stream ends in a newline character, it will be stripped.
<P>
<DD><DL>
<DT><B>Throws:</B>
<DD><CODE>java.io.IOException</CODE></DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../com/google/android/gcm/server/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../com/google/android/gcm/server/Result.html" title="class in com.google.android.gcm.server"><B>PREV CLASS</B></A>&nbsp;
&nbsp;NEXT CLASS</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?com/google/android/gcm/server/Sender.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="Sender.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
</BODY>
</HTML>