Fórum

AsyncTaskCallback to Callback conversion error.

Kishan Pawar, modificado 7 Anos atrás.

AsyncTaskCallback to Callback conversion error.

New Member Postagens: 6 Data de Entrada: 02/06/16 Postagens Recentes
Hello all,

I am trying to implement the similar code as follows on the android application, but when I am writing this code, I am getting the error at the line session.setCallback(callback); . Why this should be happening and what will I have to do to resolve this. Thank you in advance.

Code:
import com.liferay.mobile.android.task.callback.AsyncTaskCallback;
import com.liferay.mobile.android.task.callback.typed.JSONArrayAsyncTaskCallback;
...
AsyncTaskCallback callback = new JSONArrayAsyncTaskCallback() {
    public void onFailure(Exception exception) {
        // Implement exception handling code
    }
    public void onSuccess(JSONArray result) {
        // Called after request has finished successfully
    }
};
// create a session first
session.setCallback(callback);
// create a service object first
service.getGroupEntries(10184, 0, 0, -1, -1);
thumbnail
Javier Gamarra, modificado 7 Anos atrás.

RE: AsyncTaskCallback to Callback conversion error.

Expert Postagens: 348 Data de Entrada: 12/02/15 Postagens Recentes
Where did you find a reference to the class JSONArrayAsyncTaskCallback, because we have to update the documentation in that page...

With the new classes in the Mobile SDK 2, the service call should be something similar to this:

		Callback callback = new JSONArrayCallback() {

			@Override
			public void onFailure(Exception exception) {

			}

			@Override
			public void onSuccess(JSONArray result) {

			}
		};
		session.setCallback(callback);
		service.getGroupEntries(10184, 0, 0, -1, -1);
Kishan Pawar, modificado 7 Anos atrás.

RE: AsyncTaskCallback to Callback conversion error.

New Member Postagens: 6 Data de Entrada: 02/06/16 Postagens Recentes
Initially thank you Javier for your reply.

I found the reference to class JSONArrayAsyncTaskCallback here: https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-2/invoking-services-asynchronously-from-your-android-app

I used JSONArrayCallback, but the setCallback() method of Session class requires the AsyncTaskCallBack object as its parameter.

So when I pass the AsyncTaskCallBack object as a parameter to setCallback() method, it demands for the parameter to be of Callback class type.

So I am getting the error either ways. You mentioned about the Mobile SDK 2. Is it the new Mobile SDK? If yes, can you share the URL for the same?

I've one more question for you, are the Mobile SDK versions dependent on Liferay versions like 6.1,6.2 or 7.0 and so on. If Yes, then what Mobile SDK should I use for the Liferay version 6.2? I am currently using Liferay version 6.2.

Thanks in advance and waiting for your swift response.
thumbnail
Javier Gamarra, modificado 7 Anos atrás.

RE: AsyncTaskCallback to Callback conversion error.

Expert Postagens: 348 Data de Entrada: 12/02/15 Postagens Recentes
Which version of the Mobile SDK are you using? (in your dependencies, what is the version specified?)

You should use the latest releases that are compatible with both 7.0 and 6.2, here.

I've one more question for you, are the Mobile SDK versions dependent on Liferay versions like 6.1,6.2 or 7.0 and so on. If Yes, then what Mobile SDK should I use for the Liferay version 6.2? I am currently using Liferay version 6.2.