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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:28:17+00:00 2026-06-06T20:28:17+00:00

I have some activity were user goes through it and finally send the selected

  • 0

I have some activity were user goes through it and finally send the selected data to the server to save in a db. the process is like this

activity1 user logs into the app and clicks OK
if sucessfull – activity2 the customer list is loaded in AutoCompleteTextView from the remote server.
The user selects the customer and goes to the next activity3
In acitivity3 user selects some data and send it to the server.Now when the sent is successfull I want the user to see activity2,which i am able to.But when i again select a customer from the autocomplete,i get NPEx. why??is the data erased when i move from one activity to the next.so in my case the data loaded in activity2 from the remote db is no more available i.e. the arraylist is null when i return to it.

i get the error on this line — for (Customer customer : customers)

 @Override
    public void onItemClick(AdapterView<?> adapter, View view, int pos, long rowId) {       
        String cusAddr = null;

            int cusID = BaseKaizenActivity.getStorageManager().getCustomerId(customerTextView.getText().toString());
            Log.d("CUSTOMER ID", Integer.toString(cusID));
            for (Customer customer : customers) { 
                if (Integer.parseInt(customer.getId()) == cusID) { 
                     cusAddr = customer.getAddress(); 
                }
            }

        customerAddr.setTypeface(tf); 
        customerAddr.setText(Farsi.Convert(cusAddr)); 

        //customerAddr.setText(cusAddr);    

    }

here is the log of the error

06-25 07:46:42.854: W/dalvikvm(572): threadid=1: thread exiting with uncaught exception      (group=0x40015560)
06-25 07:46:42.864: E/AndroidRuntime(572): FATAL EXCEPTION: main
06-25 07:46:42.864: E/AndroidRuntime(572): java.lang.NullPointerException
06-25 07:46:42.864: E/AndroidRuntime(572):  at     com.pda.kaizen.activity.MainMenuActivity.onItemClick(MainMenuActivity.java:144)
06-25 07:46:42.864: E/AndroidRuntime(572):  at android.widget.AutoCompleteTextView.performCompletion(AutoCompleteTextView.java:952)
06-25 07:46:42.864: E/AndroidRuntime(572):  at android.widget.AutoCompleteTextView.access$1400(AutoCompleteTextView.java:92)
06-25 07:46:42.864: E/AndroidRuntime(572):  at android.widget.AutoCompleteTextView$DropDownItemClickListener.onItemClick(AutoCompleteTextView.java:1489)
06-25 07:46:42.864: E/AndroidRuntime(572):  at android.widget.AdapterView.performItemClick(AdapterView.java:284)
06-25 07:46:42.864: E/AndroidRuntime(572):  at android.widget.ListView.performItemClick(ListView.java:3513)
06-25 07:46:42.864: E/AndroidRuntime(572):  at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
06-25 07:46:42.864: E/AndroidRuntime(572):  at android.os.Handler.handleCallback(Handler.java:587)
06-25 07:46:42.864: E/AndroidRuntime(572):  at android.os.Handler.dispatchMessage(Handler.java:92)
06-25 07:46:42.864: E/AndroidRuntime(572):  at android.os.Looper.loop(Looper.java:123)
06-25 07:46:42.864: E/AndroidRuntime(572):  at android.app.ActivityThread.main(ActivityThread.java:3683)
06-25 07:46:42.864: E/AndroidRuntime(572):  at java.lang.reflect.Method.invokeNative(Native Method)
06-25 07:46:42.864: E/AndroidRuntime(572):  at java.lang.reflect.Method.invoke(Method.java:507)
06-25 07:46:42.864: E/AndroidRuntime(572):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-25 07:46:42.864: E/AndroidRuntime(572):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-25 07:46:42.864: E/AndroidRuntime(572):  at dalvik.system.NativeStart.main(Native Method)

public class MainMenuActivity extends BaseKaizenActivity implements OnItemClickListener {

public AutoCompleteTextView customerTextView;
public EditText customerAddr;
private int customerId;
private List<Customer> customers;
private String customerName;
private Typeface tf;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mainmenu);
    Log.d("INSIDE MAINMENU ACTIVITY", "INSIDE MAINMENU ACTIVITY");
    tf = Farsi.GetFarsiFont(this);

    customerTextView = (AutoCompleteTextView) findViewById(R.id.cusName_CB);
    customerTextView.setOnItemClickListener(this);
    customerTextView.setThreshold(0);
    customerTextView.setHint("Type Customer name");
    customerAddr = (EditText) findViewById(R.id.editText_cusAddress);

    // check loaded customers and products
    // if haven't loaded - need to load
    if (BaseKaizenActivity.getStorageManager().getCustomers().size() == 0) {
        progressDialog = ProgressDialog.show(this, "Please Wait", "Loading customer list");
        loadCustomers();
    }
    else {
        handleSuccess(BaseKaizenActivity.getStorageManager().getCustomers());
    }
}

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.order_menu:
            customerName = customerTextView.getText().toString();

            if (!customerName.isEmpty() && (customerId = BaseKaizenActivity.getStorageManager().getCustomerId(customerName)) != 0) {
                Log.d("----", " customer_id : " + customerId);
                showOrderScreen(customerId);
            }
            else {
                Toast.makeText(this, "Select a customer", Toast.LENGTH_LONG).show();
            }

            break;
        case R.id.customer_menu:
            //TODO - need implement 
            Toast.makeText(this, "You pressed the Customer!", Toast.LENGTH_LONG).show();
            break;
    }
    return true;
}


private void loadCustomers() {
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            try{
                customers = getConnection().getCustomers();
                BaseKaizenActivity.getStorageManager().setCustomers(customers);
                Log.d("---", "loadedddddddd : customers: " + customers.size());
                for(Customer c : customers)
                {
                    Log.d("Customer name  ", c.getName());
                }
                handleSuccess(customers);

            }
            catch (Exception exc) {
                Log.d("--- ERROR ---", exc.getMessage());
                handleException(exc.getMessage());
            }
        }
    });
    thread.start();
}



private void handleSuccess(final List<Customer> customers) {
    runOnUiThread(new Runnable() {
        @Override 
        public void run() {
            final ArrayAdapter<Customer> customerSpinner = new ArrayAdapter<Customer>(MainMenuActivity.this,
                    android.R.layout.simple_spinner_item, customers);
            customerSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            customerTextView.setAdapter(customerSpinner);

            if (progressDialog != null) {
                progressDialog.dismiss();
                progressDialog = null;
            }
        }
    });
}

@SuppressWarnings("unchecked")
private void showOrderScreen(int cusstomerId) {
    showActivity(OrderActivity.class, new Pair<String, Integer>("CUSTOMER_ID", cusstomerId));
}


@Override
public void onItemClick(AdapterView<?> adapter, View view, int pos, long rowId) {       
    String cusAddr = null;

        int cusID = BaseKaizenActivity.getStorageManager().getCustomerId(customerTextView.getText().toString());
        Log.d("CUSTOMER ID", Integer.toString(cusID));

        if(customers.isEmpty())
        {
            loadCustomers();
        }
        for (Customer customer : customers) { 
            if (Integer.parseInt(customer.getId()) == cusID) { 
                 cusAddr = customer.getAddress(); 
            }
        }

    customerAddr.setTypeface(tf); 
    customerAddr.setText(Farsi.Convert(cusAddr)); 

    //customerAddr.setText(cusAddr);    

}

}

  • 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-06T20:28:18+00:00Added an answer on June 6, 2026 at 8:28 pm

    I solved the issue and the problem was that when I would return the previous activity the arraylist was empty and did not contain the data which it had from the previous search. I fixed this issue by loading the data again in the OnCreate method.

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

Sidebar

Related Questions

I have an activity that lets the user load some data when they press
In my activity I have some links that when user click on it, WebView
in the first activity of my app i have created some fields as like
I have some data I load into the database the first time a user
I have some Javascript attached to the Service Activity form which fires OnLoad. It
In an Activity, I have some snippet of code that fires off a Message:
I have some problem with Android AsyncTask. There is an Activity which contains some
I have an activity that some times OutOfMemory exception occurs in some parts of
I have an activity with some views, after doing some stuff I want to
In my activity i have to show some images. I used gridview in my

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.