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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:49:11+00:00 2026-06-14T06:49:11+00:00

I’m a beginner in android development. I wrote my app that gets data from

  • 0

I’m a beginner in android development. I wrote my app that gets data from webservice.
In the first place it works, but when I edited and added a column of data in my app
it is showing some exceptions like this-

11-02 07:56:47.721: D/AndroidRuntime(686): Shutting down VM
11-02 07:56:47.721: W/dalvikvm(686): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
11-02 07:56:47.741: E/AndroidRuntime(686): FATAL EXCEPTION: main
11-02 07:56:47.741: E/AndroidRuntime(686): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.possampleproject/com.app.possampleproject.WelcomeActivity}: java.lang.NullPointerException
11-02 07:56:47.741: E/AndroidRuntime(686):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
11-02 07:56:47.741: E/AndroidRuntime(686):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
11-02 07:56:47.741: E/AndroidRuntime(686):  at android.app.ActivityThread.access$600(ActivityThread.java:122)
11-02 07:56:47.741: E/AndroidRuntime(686):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
11-02 07:56:47.741: E/AndroidRuntime(686):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-02 07:56:47.741: E/AndroidRuntime(686):  at android.os.Looper.loop(Looper.java:137)
11-02 07:56:47.741: E/AndroidRuntime(686):  at android.app.ActivityThread.main(ActivityThread.java:4340)
11-02 07:56:47.741: E/AndroidRuntime(686):  at java.lang.reflect.Method.invokeNative(Native Method)
11-02 07:56:47.741: E/AndroidRuntime(686):  at java.lang.reflect.Method.invoke(Method.java:511)
11-02 07:56:47.741: E/AndroidRuntime(686):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-02 07:56:47.741: E/AndroidRuntime(686):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-02 07:56:47.741: E/AndroidRuntime(686):  at dalvik.system.NativeStart.main(Native Method)
11-02 07:56:47.741: E/AndroidRuntime(686): Caused by: java.lang.NullPointerException
11-02 07:56:47.741: E/AndroidRuntime(686):  at com.app.possampleproject.WelcomeActivity.onCreate(WelcomeActivity.java:30)
11-02 07:56:47.741: E/AndroidRuntime(686):  at android.app.Activity.performCreate(Activity.java:4465)
11-02 07:56:47.741: E/AndroidRuntime(686):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
11-02 07:56:47.741: E/AndroidRuntime(686):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
11-02 07:56:47.741: E/AndroidRuntime(686):  ... 11 more

First intent I can run but when i go to next intent it gives error

MainActivity.java (First intent that i can run)

package com.app.possampleproject;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {
    final String TAG = "boolean";
    EditText username,password;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        username = (EditText)findViewById(R.id.username);
        final String user = new String(username.getText().toString());
        password = (EditText)findViewById(R.id.password);
        final String pass = new String(password.getText().toString());

        Button login = (Button)findViewById(R.id.button1);
        final String trueuser = new String("myusername");
        final String truepass = new String("mypassword");
        login.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                if(username.getText().toString().equals(trueuser) && password.getText().toString().equals(truepass)){
                    Toast.makeText(MainActivity.this, "Login success", Toast.LENGTH_SHORT).show();
                    changepage();

                }else{
                    Toast.makeText(MainActivity.this, "Wrong username or password !!", Toast.LENGTH_SHORT).show();

                }

            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    public void changepage(){
        Intent i = new Intent(this,WelcomeActivity.class);
        startActivity(i);
    }
}

WelcomeActivity.java (Second intent I can’t run and get error at this point)

package com.app.possampleproject;

import java.util.Calendar;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class WelcomeActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.welcome_page);
        // set status update label.
        SharedPreferences prefs = getSharedPreferences("date", MODE_PRIVATE);
        String dateText = prefs.getString("date", "");
        TextView date = (TextView) findViewById(R.id.textupdate);
        date.setText(dateText);
        // button activity
        Button sale_but = (Button) findViewById(R.id.sale);
        Button request_but = (Button) findViewById(R.id.request);
        Button update_but = (Button) findViewById(R.id.update);
        sale_but.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                changepage();

            }
        });

        request_but.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                changepageRequest();

            }
        });

        update_but.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                setdate();

            }
        });

    }

    public void changepage() {
        Intent i = new Intent(this, SaleActivity.class);
        startActivity(i);
    }

    public void changepageRequest() {
        Intent i = new Intent(this, RequestActivity.class);
        startActivity(i);
    }

    public void setdate() {
        Calendar c = Calendar.getInstance();
        int seconds = c.get(Calendar.SECOND);
        int min = c.get(Calendar.MINUTE);
        int hour = c.get(Calendar.HOUR);
        int day = c.get(Calendar.DATE);
        int mouth = c.get(Calendar.MONTH);
        int year = c.get(Calendar.YEAR);
        SharedPreferences prefs = getSharedPreferences("date", MODE_PRIVATE);
        Editor mEditor = prefs.edit();
        mEditor.putString("date", day + "/" + mouth + "/" + year + "  " + hour
                + ":" + min + ":" + seconds);
        mEditor.commit();
        TextView date = (TextView) findViewById(R.id.textupdate);
        date.setText(day + "/" + mouth + "/" + year + "  " + hour + ":" + min
                + ":" + seconds);

    }

}

Same Activity I edited at this intent before it gve errors

package com.app.possampleproject;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;

public class SaleActivity extends Activity {
    @SuppressLint("NewApi")
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sale_page);

        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                    .permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }

        Button cancel_but = (Button) findViewById(R.id.cancel);
        Button submit_but = (Button) findViewById(R.id.submit);

        cancel_but.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                changeToWelcome();

            }
        });

        final Button btn1 = (Button) findViewById(R.id.button1);
        // Perform action on click
        btn1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                SearchData();
            }
        });

    }

    public void changeToWelcome() {
        Intent i = new Intent(this, WelcomeActivity.class);
        startActivity(i);
    }

    public void SearchData() {
        // listView1
        final ListView lisView1 = (ListView) findViewById(R.id.listView1);

        // editText1
        final EditText inputText = (EditText) findViewById(R.id.editText1);

        String url = "http://lab.richma.net/getJSONR.php";

        // Paste Parameters
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("txtKeyword", inputText.getText()
                .toString()));

        try {
            JSONArray data = new JSONArray(getJSONUrl(url, params));

            final ArrayList<HashMap<String, String>> MyArrList = new ArrayList<HashMap<String, String>>();
            HashMap<String, String> map;

            for (int i = 0; i < data.length(); i++) {
                JSONObject c = data.getJSONObject(i);

                map = new HashMap<String, String>();
                map.put("ProductID", c.getString("ProductID"));
                map.put("Size", c.getString("Size"));
                map.put("Colour", c.getString("Colour"));
                map.put("Price", c.getString("Price"));
                map.put("Quantity", c.getString("Quantity"));
                MyArrList.add(map);

            }

            // item list want to sale

            SimpleAdapter sAdap;
            sAdap = new SimpleAdapter(SaleActivity.this, MyArrList,
                    R.layout.activity_column, new String[] { "ProductID",
                            "Size", "Colour", "Price", "Quantity" }, new int[] {
                            R.id.ColProductID, R.id.ColSize, R.id.ColColour,
                            R.id.ColPrice, R.id.ColQuantity });
            lisView1.setAdapter(sAdap);

            final AlertDialog.Builder viewDetail = new AlertDialog.Builder(this);
            // OnClick Item
            lisView1.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> myAdapter, View myView,
                        int position, long mylng) {

                    String strProductID = MyArrList.get(position)
                            .get("ProductID").toString();
                    String sSize = MyArrList.get(position).get("Size")
                            .toString();
                    String strColour = MyArrList.get(position).get("Colour")
                            .toString();
                    String strPrice = MyArrList.get(position).get("Price")
                            .toString();
                    String strQuantity = MyArrList.get(position)
                            .get("Quantity").toString();

                    viewDetail.setIcon(android.R.drawable.btn_star_big_on);
                    viewDetail.setTitle("Product Detail");
                    viewDetail.setMessage("ProductID : " + strProductID + "\n"
                            + "Size : " + sSize + "\n" 
                            + "Colour : " + strColour + "\n" 
                            + "Price : " + strPrice + "\n"
                            + "Quantity : " + strQuantity);
                    viewDetail.setPositiveButton("OK",
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog,
                                        int which) {
                                    // TODO Auto-generated method stub
                                    dialog.dismiss();
                                }
                            });
                    viewDetail.setNegativeButton("Cancel",
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog,
                                        int which) {
                                    // TODO Auto-generated method stub
                                    dialog.dismiss();
                                }
                            });
                    viewDetail.show();

                }
            });

            // sale list retrieve

        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public String getJSONUrl(String url, List<NameValuePair> params) {
        StringBuilder str = new StringBuilder();
        HttpClient client = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);

        try {
            httpPost.setEntity(new UrlEncodedFormEntity(params));
            HttpResponse response = client.execute(httpPost);
            StatusLine statusLine = response.getStatusLine();
            int statusCode = statusLine.getStatusCode();
            if (statusCode == 200) { // Download OK
                HttpEntity entity = response.getEntity();
                InputStream content = entity.getContent();
                BufferedReader reader = new BufferedReader(
                        new InputStreamReader(content));
                String line;
                while ((line = reader.readLine()) != null) {
                    str.append(line);
                }
            } else {
                Log.e("Log", "Failed to download file..");
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str.toString();
    }

}        

If you want more information code please tell me .. Thanks a lots

Edited: This is my welcome_page.xml, thanks for answer

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@drawable/wood">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="branch :"
            android:textSize="20dp" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="branch1"
            android:textSize="20dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/sale"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="sale" />

        <Button
            android:id="@+id/request"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="request" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="update list"
            android:textSize="20dp" /> 

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:ems="10"
            android:inputType="textMultiLine" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/update"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="update" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical" >    

            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_weight="1"
                android:text="Recently update" />    

            <TextView
                android:id="@+id/textupdate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:text="27/10/55" />

        </LinearLayout>   
    </LinearLayout>    
</LinearLayout>
  • 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-14T06:49:12+00:00Added an answer on June 14, 2026 at 6:49 am

    The lines

    Caused by: java.lang.NullPointerException
    at com.app.possampleproject.WelcomeActivity.onCreate(WelcomeActivity.java:30)

    Indicates that the root cause is at line 30 of your WelcomeActivity.java, where you are using a variable which is null.

    Possibly findViewById(R.id.sale); is returning null because it can’t find the button. Are you sure it exists and has that ID?

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.