question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to get return value onResponse or onError ?

See original GitHub issue

i must admit im new in java… sorry for including this in issues hope it would help others inexperience people who using this library. how to get return value in void onResponse Method ?

i have already using OptimusHttp that using Volley in their base connection library. as i know on that library it would support to return any value from OnSuccess method by using Interface Callback.

can u help me how to accomplish it using this library ?


 api.get(this.host+"login")
                .setPriority(Priority.HIGH)
                .build()
                    .getAsJSONObject(new JSONObjectRequestListener() {
                        @Override
                        public void onResponse(JSONObject response) {

                            try {
                                     // need to return value here such as 
                                   **return response;  --> error**                      
                           } catch (Exception e) {
                                System.out.println(e.toString());
                            }
                        }

                        @Override
                        public void onError(ANError anError) {
                                messageToast("error");
                        }

                });

thanks u

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
amitshekhariitbhucommented, Feb 14, 2017

This library always does the network in the background thread and return in the main thread by default.

1reaction
navoteracommented, Mar 23, 2017

thank u sir. "onResponse returns in main thread after doing work in " this line help me understand the thread involved on onResponse method i really appreciate for all your answer and your time sir @amitshekhariitbhu

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to return value from onResponse - java - Stack Overflow
One way to do what you're trying to implement, is with a set of Callbacks. You put 2 parameters in your method. onSuccess...
Read more >
Rest.li Filters - LinkedIn Open Source
onError is invoked when an exception occurs in one of the filter's methods or if it receives a response error from the previous...
Read more >
android - How can I return value from onResponse of Retrofit v2
Important things to notice: The method returns void. ... There's another option where you could make your code reactive.
Read more >
Consuming APIs with Retrofit | CodePath Android Cliffnotes
Assuming you have the JSON response already, go to jsonschema2pojo. Make sure to select JSON as the Source Type: Set the Annotation style...
Read more >
Modeling Retrofit Responses With Sealed Classes and ...
In this post, you will cover how to model Retrofit responses with Coroutines and Sealed classes to reduce code complexity and make your ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found