Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9073175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:21:18+00:00 2026-06-16T18:21:18+00:00

I’m trying to implement a login feature in my Android app using Lukencode ‘s

  • 0

I’m trying to implement a login feature in my Android app using Lukencode‘s RestClient class. I have a class named UserFunctions to retrieve JSONObject via RestClient:

public class UserFunctions {

    private RestClient restClient;
    private String json;
    private Context mContext;

    private static String login_tag = "login";
    private static String register_tag = "register";

    // constructor
    public UserFunctions(Context context){
        restClient = new RestClient("http://10.0.2.2:81/HGourmet/user");
        mContext = context;
    }

    /**
     * function make Login Request
     * @param email
     * @param password
     * */
   public JSONObject loginUser(String email, String password){
        // Building Parameters      
        restClient.AddParam("tag", login_tag);
        restClient.AddParam("email", email);
        restClient.AddParam("password", password);

        // getting JSON Object
        try{
    restClient.Execute(RequestMethod.POST);
    }catch(Exception e){
        e.printStackTrace();
    }               
    json = restClient.getResponse();

        JSONObject jObj = null;
        try {
            jObj = new JSONObject(json);
        } catch (JSONException e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
        }
        return jObj;
    }

And below is what I get in logcat:

01-06 09:01:05.805: E/Trace(1819): error opening trace file: No such file or directory (2)
01-06 09:02:05.485: E/AndroidRuntime(1819): FATAL EXCEPTION: main
01-06 09:02:05.485: E/AndroidRuntime(1819): java.lang.NullPointerException
01-06 09:02:05.485: E/AndroidRuntime(1819):     at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at org.json.JSONTokener.nextValue(JSONTokener.java:94)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at org.json.JSONObject.<init>(JSONObject.java:154)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at org.json.JSONObject.<init>(JSONObject.java:171)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at com.hanu.hgourmet.library.UserFunctions.loginUser(UserFunctions.java:49)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at com.hanu.hgourmet.LoginActivity$1.onClick(LoginActivity.java:56)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at android.view.View.performClick(View.java:4202)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at android.view.View$PerformClick.run(View.java:17340)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at android.os.Handler.handleCallback(Handler.java:725)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at android.os.Handler.dispatchMessage(Handler.java:92)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at android.os.Looper.loop(Looper.java:137)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at android.app.ActivityThread.main(ActivityThread.java:5039)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at java.lang.reflect.Method.invokeNative(Native Method)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at java.lang.reflect.Method.invoke(Method.java:511)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-06 09:02:05.485: E/AndroidRuntime(1819):     at dalvik.system.NativeStart.main(Native Method)

I really hope that someone would help me pinpoint the reason of this problem. Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T18:21:19+00:00Added an answer on June 16, 2026 at 6:21 pm

    I won’t expand on how you should do this, but only on why it happens. An AsyncTask, by definition, is asynchronous. This means that when you execute it, it does its job in parallel, in a different thread. So you can’t expect it to be terminated right after execute() has been called (else it would be called SyncTask, and wouldn’t have any reason to exist).

    See AsyncTask as a toaster. When you start the toaster (execute the AsyncTask), it toasts your bread, but doesn’t return the toasted bread immediately. It takes some time to toast it. While it’s toasting your bread, you can do something else (and thus not freeze the UI thread completely). And when it has finished toasting your bread, it notifies you with a ding! that the bread is toasted. That’s the same thing here. You should only start using json (the toasted bread), when the AsyncTask notifies you that it has finished executing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
We're building an app, our first using Rails 3, and we're having to build
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.