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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:12:49+00:00 2026-06-10T05:12:49+00:00

I am not so new to android development, but I am not able to

  • 0

I am not so new to android development, but I am not able to figure out why this silly issue is coming up. All I am doing is starting an activity on application start and it crashes giving nullpointerException. Please check my code below.

May be last-office-hours are making me blind.

Logcat:

08-23 18:19:19.359: E/AndroidRuntime(798): FATAL EXCEPTION: main
08-23 18:19:19.359: E/AndroidRuntime(798): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.click4tab.orderformnew/com.click4tab.orderformnew.Login}: java.lang.NullPointerException

Login.java :

public class Login extends Activity {

    Button loginButton;
    EditText id, password;
    String sID, sPassword;
    TestAdapter obj;
    Context loginContext;
    public static int loginSuccessful;

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

        //Initialising variables 

        loginButton = (Button)findViewById(R.id.button1);
        id = (EditText)findViewById(R.id.editText1);
        password = (EditText)findViewById(R.id.editText2);

        obj = new TestAdapter(loginContext);


        sID = id.getText().toString();
        sPassword = password.getText().toString();

        StringBuffer buf = new StringBuffer();
        buf.append(sID + ":::" + sPassword);


        TestAdapter.params = new ArrayList<NameValuePair>();
        TestAdapter.params.add(new BasicNameValuePair("tag", "login"));
        TestAdapter.params.add( new BasicNameValuePair("query", buf.toString()));

        loginButton.setOnClickListener( new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                //send login information to authenticate user

                obj.new Read().execute("");

//              Intent i = new Intent("mainActivity");
//              startActivity(i);

            }
        });

    }



}

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.click4tab.orderformnew"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="15" />
    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="mainActivity" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity
            android:name=".Login"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>

login.xml :

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginTop="194dp"
            android:text="ID"
            android:textAppearance="?android:attr/textAppearanceMedium" />


        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/textView1"
            android:layout_alignBottom="@+id/textView1"
            android:layout_alignLeft="@+id/button1"
            android:ems="10" >

            <requestFocus />
        </EditText>

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/editText1"
            android:layout_marginTop="29dp"
            android:text="Password"
            android:textAppearance="?android:attr/textAppearanceMedium" />




        <EditText
            android:id="@+id/editText2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/textView2"
            android:layout_alignBottom="@+id/textView2"
            android:layout_alignLeft="@+id/button1"
            android:layout_alignParentRight="true"
            android:ems="10"
            android:inputType="textPassword" />


        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/editText2"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="19dp"
            android:layout_marginTop="16dp"
            android:text="Login" />

    </RelativeLayout>
  • 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-10T05:12:51+00:00Added an answer on June 10, 2026 at 5:12 am

    You have not instantiated loginContext

    Do

    loginContext = this;
    

    before

    obj = new TestAdapter(loginContext);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a new web-browser for android, but this browser is not
I am new to Android and Eclipse development, but not new to software development
I am new to Android and Eclipse development, but not new to software development
I am totally new to Android development. I'm not looking for code but what
I am still pretty new to Android development, and I have not been able
Extreme Android developer newbie here...well, new to Android development, not development in general. I
I am relatively a new Android developer and I am not able to understand
I'm new to Java/Eclipse/Android, so this is probably an easy (if not stupid) question:
I'm new to Java but not to programming. I'm reading the book Beginning Android
I'm pretty new to android development, so I hope my question is easy, but

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.