Android 通过改造构建url

Android 通过改造构建url,android,retrofit,Android,Retrofit,我正在使用改装来访问有关电视频道的数据。 我拥有的url是: http://ott.online.meo.pt/catalog/v7/Channels?UserAgent=AND&$filter=substringof(%27MEO_Mobile%27,AvailableOnChannels)%20and%20IsAdult%20eq%20false&$orderby=ChannelPosition%20asc&$inlinecount=allpages 在reform

我正在使用改装来访问有关电视频道的数据。 我拥有的url是:

http://ott.online.meo.pt/catalog/v7/Channels?UserAgent=AND&$filter=substringof(%27MEO_Mobile%27,AvailableOnChannels)%20and%20IsAdult%20eq%20false&$orderby=ChannelPosition%20asc&$inlinecount=allpages
在reformation.Builder()中,我将“主url”(
http://ott.online.meo.pt
)和在接口
端点中
url的其余部分。 我这样做,但我不知道如何放置完整的url

interface Endpoint {
    @Headers("User-Agent: AND")
    @GET("catalog/v7/Channels" )
    fun getChannels() : Call<SerializeChannels>
}
接口端点{
@标题(“用户代理:和”)
@获取(“目录/v7/频道”)
fun getChannels():调用
}
您的改装客户:

Retrofit retrofit = new Retrofit.Builder()
        .baseUrl("http://ott.online.meo.pt/")
        .build();
您可以用多种方式定义端点:

以下是硬编码方式:

interface Endpoint {
    @GET("catalog/v7/Channels?UserAgent=AND&filter=substringof('MEO_Mobile',AvailableOnChannels)&IsAdult=false&orderby=ChannelPosition asc&inlinecount=allpages" )
    fun getChannels() : Call<SerializeChannels>
}
接口端点{
@获取(“catalog/v7/Channels?UserAgent=AND&filter=substringof('MEO_Mobile',AvailableOnChannels)&IsAdult=false&orderby=ChannelPosition asc&inlinecount=allpage”)
fun getChannels():调用
}
您还可以按如下方式使用查询参数:

interface Endpoint {
   @GET("catalog/v7/Channels")
   fun getChannels( @Query("UserAgent") String agent, @Query("filter") String filters,@Query("IsAdult") String isAdult,@Query("orderby") String sort,@Query("inlinecount") String count) : Call<SerializeChannels>
}
接口端点{
@获取(“目录/v7/频道”)
fun getChannels(@Query(“UserAgent”)字符串代理、@Query(“filter”)字符串过滤器、@Query(“IsAdult”)字符串IsAdult、@Query(“orderby”)字符串排序、@Query(“inlinecount”)字符串计数):调用
}

Reformation提供了关于如何向URL添加查询参数的非常好的文档:。如果查询参数不应该是动态的,您也可以将整个URL字符串用作
@GET
的参数。根据文档,将整个URL字符串用作@GET?的参数是正确的-是的。