tccpg288 tccpg288 - 1 year ago 89
reST (reStructuredText) Question

FlickR API - Query Based on EditText

I have successfully determined how to make a call to the FlickR API. However, I am having difficulty determining how I search all of the FlickR photos based on a search term entered by the user.

I believe the search term should be entered into the "tags" component of the FlickR API, however I do not know how to link my Edit Text variable (mQuery) to the FlickR API tag:

public class MainActivity extends AppCompatActivity {

private EditText mSearchTerm;
private Button mRequestButton;
private String mQuery;

protected void onCreate(Bundle savedInstanceState) {

mSearchTerm = (EditText) findViewById(;
mRequestButton = (Button) findViewById(;
mRequestButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
mQuery = mSearchTerm.getText().toString();
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
Retrofit retrofit = new Retrofit.Builder()

ApiInterface apiInterface = retrofit.create(ApiInterface.class);
Call<List<Photo>> call = apiInterface.getPhotos(mQuery);
call.enqueue(new Callback<List<Photo>>() {
public void onResponse(Call<List<Photo>> call, Response<List<Photo>> response) {


public void onFailure(Call<List<Photo>> call, Throwable t) {




//Synchronous vs. Asynchronous
public interface ApiInterface {
@GET("?&<Ali>&api_key=1c448390199c03a6f2d436c40defd90e&format=json") //
Call<List<Photo>> getPhotos(@Query("q") String photoSearchTerm);


Answer Source

Try this out, this is a search API for Flickr

  public static final String BASE_URL = "";

  Call<FlickrModel> getImages(@Query("text") String query);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download