Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, you can pass them in runtime. As a matter of fact, pretty much exactly as you typed it out. This would be in your API interface class, named say <strong>SecretApiInterface.java</strong></p> <pre><code>public interface SecretApiInterface { @GET("/secret_things") SecretThing.List getSecretThings(@Header("Authorization") String token) } </code></pre> <p>Then you pass the parameters to this interface from your request, something along those lines: (this file would be for example <strong>SecretThingRequest.java</strong>) </p> <pre><code>public class SecretThingRequest extends RetrofitSpiceRequest&lt;SecretThing.List, SecretApiInteface&gt;{ private String token; public SecretThingRequest(String token) { super(SecretThing.List.class, SecretApiInterface.class); this.token = token; } @Override public SecretThing.List loadDataFromNetwork() { SecretApiInterface service = getService(); return service.getSecretThings(Somehow.Magically.getToken()); } } </code></pre> <p>Where <code>Somehow.Magically.getToken()</code> is a method call that returns a token, it is up to you where and how you define it. </p> <p><strong><em>You can of course have more than one <code>@Header("Blah") String blah</code> annotations in the interface implementation, as in your case!</em></strong> </p> <p>I found it confusing too, <strong><a href="http://square.github.io/retrofit/javadoc/index.html" rel="noreferrer">the documentation</a></strong> clearly says it <strong>replaces</strong> the header, but it <strong>DOESN'T</strong>!<br> It is in fact added as with <code>@Headers("hardcoded_string_of_liited_use")</code> annotation </p> <p>Hope this helps ;)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload