Translating method calls to REST calls
General Hints

Naming

Your code does not respect Java Naming Conventions. The constants (static final members) names should be ALL_UPPER_CASE.

Singelton Pattern

Do not use the Singelton pattern. It makes it hard to reuse the code using this one in general and to test (in UnitTests) in particular.

BTW: you did it wrong.

Comments

Comments should explain why the code is like it is.

Your comments simply lie.

Following your comments the first method in JsonHttpResponseHandler should throw the exception, not the second.

This problem is quite common in code under development. Someone changes the behavior of the code but does not adjust the comments, turning them into lies.

So just delete the comments.

Supporting DRY

Often you don't have pure duplicated code. In most cases you have similar looking code which you usually quite easily can change to equal code by simple refactorings and/or by applying design patterns. 

This goes basically in 3 steps.


identify similar code
make similar code the same
remove the duplication


Since this process is expected not to change the behavior of your application you should better have UnitTest that fix the desired behavior so that you get immediate response when you broke something. 

Identify similar code

The biggest block of duplication is the anonymous inner class of type JsonHttpResponseHandler which is created twice with the almost same content.

The only difference is the check for the user being null.

Make similar code the same

In this step you convert individual similar parts of your code to look exactly the same. 
Avoid typing as much as possible and rely on your IDEs refactorings like extract to local variable, rename in file and alike.

If the execution context of the first JsonHttpResponseHandler implementation guarantees that user never references null then you could simply copy the null check to it to make the same as the second.

Skip the rest of the section if that applies.



If not you should refactor out the difference. You could do so  by introducing a new interface:

public class Caller {
  private interface ActivityCaller{
     void handle(ShareActivity activity,JSONObject user);
  }


Then you implement the interface with the respective behavior before creating the instance of JsonHttpResponseHandler:

// first version
RequestParams params = new RequestParams(map);
ActivityCaller activityCaller = (a,user)-&gt; a.handleUser(user); // java8 Lambda Style, lambda parameter name 'a' must differ from the methods parameter name
get(registerUrl, params, new JsonHttpResponseHandler() {
  @Override
  public void onSuccess(int statusCode, Header[] headers, JSONObject user) {
     activityCaller.handleUser(activity,user);
  }
  // .. no changes after here




// second versionRequestParams params = new RequestParams(map);
ActivityCaller activityCaller = new ActivityCaller(){ // traditional annonymous inner class
 @Override
  public void handle(ShareActivity activity,JSONObject user){
    if(user!=null){
        activity.handleUser(user);
    }else {
        activity.registerUser();
    }
  }
}
get(registerUrl, params, new JsonHttpResponseHandler() {
  @Override
  public void onSuccess(int statusCode, Header[] headers, JSONObject user) {
     activityCaller.handleUser(activity,user);
  }
  // .. no changes after here


Remove the duplication

Now both anonymous inner class implementations of JsonHttpResponseHandler are exactly the same. Use your IDEs convert anonymous to inner class refactoring to replace both occurrences. 

This creates a new inner class:

// assumed you copied the `null` check
public class Caller {
  private static class JsonHttpResponseHandlerImpl{
    private final ShareActivity activity; // if you copied the null check
    JsonHttpResponseHandlerImpl(ShareActivity activity){
      this.activity = activity;
    }
    @Override
    public void onSuccess(int statusCode, Header[] headers, JSONObject user) {
        if(user!=null){
            activity.handleUser(user);
        }else {
            activity.registerUser();
        }
    }
    @Override
    public void onSuccess(int statusCode, Header[] headers, JSONArray array) {
        throw new RuntimeException("array in stead of object");
    }
  }


and both of your methods change to:

   RequestParams params = new RequestParams(map);
   get(registerUrl, params, new JsonHttpResponseHandlerImpl(activity));


As a result you have even more common code in both methods which you could easily move to the common get method.

What's left in your getUser() methods it the creation of the map with different content and the implementations of the new ActivityCaller interface if you decided for this way.