how to return value from onSuccess to other function in android?

0 votes
public String getSessionID(String user) {
    String userName = user;
    App42API.initialize(getContext(),
            "******",
            "******");
    SessionService sessionService = App42API.buildSessionManager();
    sessionService.getSession(userName,new App42CallBack() {
        public void onSuccess(final Object response)
        {
            Session session = (Session)response;
            s_id = session.getSessionId();
        }
        public void onException(Exception ex)
        {
            System.out.println("Exception Message"+ex.getMessage());
        }
    });
    return s_id;
}
asked Jan 28, 2018 in Announce Your App by AH Forootan (10 points)

1 Answer

0 votes
Hi,

All the App42 APIs are async so you can not return any value from the callback onSuccess to its calling method. The best way is to write a separate method to perform a task which depends on the value you get in the onSuccess callback. Once you have that value, you call that method from the callback and pass the values as parameter.

I hope this will help.

Thanks.
answered Jan 29, 2018 by rajeev.etc (1,660 points)
I can't write this separate method , can you send a example for me ?
I tried any way but , I can't do it ... but I need it.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...