I have an url similar to http://www.myexample.com/rss/choose.php?type=level&id=2
and I want to use Retrofit in my android app. The problem is that type
is a parameter which can take different values like level
, grade
, etc.
I can't adapt Retrofit every time type
change because I get a "Annotations are not allowed here" in TestesInterface. I was looking to this post and applied to my app but it doesn't work.
static final String BASE_URL = "http://www.myexample.com/rss/";
public void start() {
Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_URL)
.addConverterFactory(SimpleXmlConverterFactory.create()).build();
TestesInterface testesInterface = retrofit.create(TestesInterface.class);
Call<Channel> call = testesInterface.loadChannel("choose.php?type=level&id=2");
call.enqueue(this);
}
My interface:
public interface TestesInterface {
@GET
Call<Channel> loadChannel(@Url type);
}
This made that every time I want to change type to a different value I should change testesInterface.loadChannel("choose.php?type=level&id=2")
. This doesn't work. Can you please help me?