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

  • Home
  • SEARCH
  • 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 9105539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:08:04+00:00 2026-06-17T02:08:04+00:00

I have a problem with android programming. I am new in this, so don’t

  • 0

I have a problem with android programming. I am new in this, so don’t be judgemental.

I built a login form and when I try to login, I get in the username textbox java.lang.NullPointerException. Here is the code:

import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import android.app.Activity;
import android.os.Bundle;
import android.view.View; 
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.content.Context;
import android.content.Intent;

public class Login extends Activity {
EditText un,pw;
TextView error;
Button ok;
Button reg;
private static Context context;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    un=(EditText)findViewById(R.id.editText1);
    pw=(EditText)findViewById(R.id.editText2);
    ok=(Button)findViewById(R.id.button1);
    reg=(Button)findViewById(R.id.button2);
    ok.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

                            // TODO Auto-generated method stub



    ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
    postParameters.add(new BasicNameValuePair("username", un.getText().toString()));

    postParameters.add(new BasicNameValuePair("password", pw.getText().toString()));



    String response = null;

    try {

    response = CustomHttpClient.executeHttpPost("<HTTP Request site>", postParameters);

    String res=response.toString();

    res= res.replaceAll("\\s+","");

    if(res.equals("1")) { 
        error.setText("Welcome to ...");
        Intent i = new Intent(context, Welcome.class);
        startActivity(i);
    }

    else

    error.setText("Sorry!! Incorrect Username or Password");

    } catch (Exception e) {

    un.setText(e.toString());

                    }
                }
            });
        }
    }

Is there any problem or a mistake that I made. Please help me. Or just give me some directions.

Thanks in advance

  • 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-17T02:08:05+00:00Added an answer on June 17, 2026 at 2:08 am

    You’re getting an error because your TextView error is never initialized. Add the following line into your onCreate():

    error=(TextView)findViewById(R.id.<textView_ID);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm abit new to programming Android App's, however I have come across a problem,
I am quite new to java android programming and I have a problem that
I am a newbie in Android programming and I have this problem: In this
I am new to Android programming and i have a problem that i can
I'm quite new to android programming and I have the following problem. I want
im new in android programming.. i have a problem here. i wanna make an
I have one problem with android calendar programming, so If there are 2 months
I have problem with android 4.0.3. I'm using the method below to get local
I'm new to Android programming . I have a list of items, when the
I have a problem programming with Android SDK 1.6. I'm doing the same things

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.