Android:Method Callback is not working
<p>I am trying to implement method callback using relection but it is not calling the desired method.Here is my main activity</p>

<pre><code>public class MainActivity extends AppCompatActivity
{
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        RetrofitCalls retrofitCalls = new RetrofitCalls();
        retrofitCalls.requestAccesstoken();
        retrofitCalls.requestDataFromServer(MainActivity.this,"onCountryListReceived");
    }

    public void onCountryListReceived(JsonObject jsonObject)
    {
        String temp = "hello";
    }
}
</code></pre>

<p>and here is the <code>requestDataServer</code> method</p>

<pre><code> public void requestDataFromServer(final Activity activity, final String callBackMethod){

    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .addInterceptor(new HeaderInterceptor())
            .build();

    retrofit = new Retrofit.Builder()
            .baseUrl(Constants.ROOT_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .client(okHttpClient)
            .build();

    Api api = retrofit.create(Api.class);
    Call&lt;JsonObject&gt; call = api.getDataFromServer(Constants.COUNTRY_LIST);
    call.enqueue(new Callback&lt;JsonObject&gt;() {
        @Override
        public void onResponse(Call&lt;JsonObject&gt; call, Response&lt;JsonObject&gt; response) {

            if(response.errorBody() != null){
                try {
                    String j1 = response.errorBody().string();
                    String temp = "hello";
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }else if(response.body() != null) {
                JsonObject jsonObject = response.body();
                JsonArray jsonArray = jsonObject.getAsJsonArray("Data");
                String temp = "hello";

                try {
                    String x = activity.getClass().toString();
                    Method method = activity.getClass().getDeclaredMethod(callBackMethod.trim(),Object.class);
                    method.invoke(activity,jsonObject);
                } catch (NoSuchMethodException e) {
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
        @Override
        public void onFailure(Call&lt;JsonObject&gt; call, Throwable t) {
            String temp = "hello";
        }
    });
}
</code></pre>

<p>why the <code>onCountryListReceived</code> is not invoked? It is giving <code>NoSuchMethodException</code>. What's the problem?</p>