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 8934807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:51:57+00:00 2026-06-15T09:51:57+00:00

I write the program, the program should give name,email and etc of textboxes and

  • 0

I write the program, the program should give name,email and etc of textboxes and send to a url but the program has stopped and NullPointerException error in run time.

I write the code of my porgram. Please read and help me. Thanks

SignUpAsync.java:

public class SignUpAsync extends AsyncTask<List<NameValuePair>,Void,String>{
@Override
protected String doInBackground(List<NameValuePair>... nameValuePairs) {

    HttpPost httpPost=new HttpPost("http://myURL.com");
    HttpClient httpClient=new DefaultHttpClient();
    HttpResponse httpRespons = null;

    try {
        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs[0]));
        httpRespons=httpClient.execute(httpPost);
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    HttpEntity entity=httpRespons.getEntity();
    InputStream is = null;
    try {
        is=entity.getContent();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return convertStreamToString(is);

}

private String convertStreamToString(InputStream is){
    BufferedReader bfReader=new BufferedReader(new InputStreamReader(is));
    StringBuilder sb=new StringBuilder();
    String line="";
    try {
        while((line=bfReader.readLine())!=null)
            //
            sb.append(line);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        is.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return sb.toString();

}   
}

SignUp.java:

public class SignUp extends Activity{

private Button signUp;
private EditText userName;
private EditText userEmail;
private EditText userPass;
private EditText userPasscode;
private EditText userPhone;

@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.rewards_signup);

    initView();

    String[] params = null;
    params[0]=userName.getText().toString();
    params[1]=userEmail.getText().toString();
    params[2]=userPass.getText().toString();
    params[3]=userPasscode.getText().toString();
    params[4]=userPhone.getText().toString();

    List<NameValuePair> nameValuePairs=new ArrayList<NameValuePair>(5);
    nameValuePairs.add(new BasicNameValuePair("User Name",params[0]));
    nameValuePairs.add(new BasicNameValuePair("User Email Id",params[1]));
    nameValuePairs.add(new BasicNameValuePair("User Password",params[2]));
    nameValuePairs.add(new BasicNameValuePair("User Passcode",params[3]));
    nameValuePairs.add(new BasicNameValuePair("User Phone Number",params[4]));

    AsyncTask<List<NameValuePair>, Void, String> async;
    async=new SignUpAsync().execute(nameValuePairs);
    try {
        String result=async.get();
        if(result!=null)
            Log.i("result", result);
        else
            Log.i("result", "null");
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ExecutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
private void initView(){
    signUp=(Button)findViewById(R.id.signup_id);
    userName=(EditText)findViewById(R.id.name_id);
    userEmail=(EditText)findViewById(R.id.email_id);
    userPass=(EditText)findViewById(R.id.password_id);
    userPasscode=(EditText)findViewById(R.id.pincode_id);
    userPhone=(EditText)findViewById(R.id.phonnum_id);
}
}

LogCat:

12-05 08:46:00.063: W/dalvikvm(15436): threadid=1: thread exiting with uncaught exception (group=0x40a7e1f8)
12-05 08:46:00.071: E/AndroidRuntime(15436): FATAL EXCEPTION: main
12-05 08:46:00.071: E/AndroidRuntime(15436): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.example.loyaltier/org.example.rewards.SignUp}: java.lang.NullPointerException
12-05 08:46:00.071: E/AndroidRuntime(15436):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at android.app.ActivityThread.access$600(ActivityThread.java:122)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at android.os.Looper.loop(Looper.java:137)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at android.app.ActivityThread.main(ActivityThread.java:4340)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at java.lang.reflect.Method.invokeNative(Native Method)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at java.lang.reflect.Method.invoke(Method.java:511)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at dalvik.system.NativeStart.main(Native Method)
12-05 08:46:00.071: E/AndroidRuntime(15436): Caused by: java.lang.NullPointerException
12-05 08:46:00.071: E/AndroidRuntime(15436):    at org.example.rewards.SignUp.onCreate(SignUp.java:35)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at android.app.Activity.performCreate(Activity.java:4465)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-05 08:46:00.071: E/AndroidRuntime(15436):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
12-05 08:46:00.071: E/AndroidRuntime(15436):    ... 11 more
12-05 08:46:01.579: I/Process(15436): Sending signal. PID: 15436 SIG: 9

Cheers.

  • 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-15T09:51:59+00:00Added an answer on June 15, 2026 at 9:51 am

    You need to initialize params:

    String[] params = new String[5];
    

    Also understand that AsyncTask#get() this line:

    String result=async.get();
    

    As described in the documentation, “Waits if necessary for the computation to complete, and then retrieves its result.” will block the main thread until the AsyncTask has completed. This defies the purpose of the AsyncTask…

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

Sidebar

Related Questions

The following line in my C program should provided All/Group/Owner read and write permissions
I write a program to verify this website: www.alipay.com which root CA cert should
I want to write a program that you give an input (number of digits
My class assignment is to write a program that has the user input a
Here I have written my name in main argument declaration but still this program
I want to write a simple Xlib program changing the mouse behavior (to give
I'm willing to write program that after 5 sec shows text that was hidden
If I write program in python 2.7 and I want to run another script
Write a program to determine whether a computer is big-endian or little-endian. bool endianness()
I write a program to delete a file from somewhere of my harddisk in

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.