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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:33:35+00:00 2026-06-10T15:33:35+00:00

I created a onDestroy method for my filter searchbar and i met with a

  • 0

I created a onDestroy method for my filter searchbar and i met with a small prob.

here is my logcat:

09-01 01:55:40.147: E/AndroidRuntime(1014): FATAL EXCEPTION: main
09-01 01:55:40.147: E/AndroidRuntime(1014): java.lang.RuntimeException: Unable to destroy activity {com.stts.sparetimetradingsystem/com.stts.sparetimetradingsystem.employer.HomepageEmployerActivity}: java.lang.NullPointerException
09-01 01:55:40.147: E/AndroidRuntime(1014):     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3655)
09-01 01:55:40.147: E/AndroidRuntime(1014):     at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3673)
09-01 01:55:40.147: E/AndroidRuntime(1014):     at android.app.ActivityThread.access$2900(ActivityThread.java:125)
09-01 01:55:40.147: E/AndroidRuntime(1014):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
09-01 01:55:40.147: E/AndroidRuntime(1014):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-01 01:55:40.147: E/AndroidRuntime(1014):     at android.os.Looper.loop(Looper.java:123)
09-01 01:55:40.147: E/AndroidRuntime(1014):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-01 01:55:40.147: E/AndroidRuntime(1014):     at java.lang.reflect.Method.invokeNative(Native Method)
09-01 01:55:40.147: E/AndroidRuntime(1014):     at java.lang.reflect.Method.invoke(Method.java:521)
09-01 01:55:40.147: E/AndroidRuntime(1014):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-01 01:55:40.147: E/AndroidRuntime(1014):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-01 01:55:40.147: E/AndroidRuntime(1014):     at dalvik.system.NativeStart.main(Native Method)
09-01 01:55:40.147: E/AndroidRuntime(1014): Caused by: java.lang.NullPointerException
09-01 01:55:40.147: E/AndroidRuntime(1014):     at com.stts.sparetimetradingsystem.employer.HomepageEmployerActivity.onDestroy(HomepageEmployerActivity.java:340)
09-01 01:55:40.147: E/AndroidRuntime(1014):     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3642)
09-01 01:55:40.147: E/AndroidRuntime(1014):     ... 11 more

This is my code:

@Override
protected void onDestroy() {
    super.onDestroy();
    searchBarEmployer.removeTextChangedListener(filterTextWatcher); <--- LINE 340
}

**EDIT
THIS IS MY LOGIN CODE That will switch to homepage after the user entered the correct credentials.

public class LoginEmployerActivity extends Activity {
Button btnLoginEmployer;
Button btnLinkToEmployerRegisterScreen;
EditText inputEmail;
EditText inputPassword;
TextView loginErrorMsg;
TextView forgotPassword;

// JSON Response node names
private static String KEY_SUCCESS = "success";
private static String KEY_ERROR = "error";
private static String KEY_ERROR_MSG = "error_msg";
private static String KEY_UID = "uid";
private static String KEY_NAME = "name";
private static String KEY_CNAME = "cname";
private static String KEY_EMAIL = "email";
private static String KEY_CREATED_AT = "created_at";
private ProgressDialog pDialog;

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

    // Importing all assets like buttons, text fields
    inputEmail = (EditText) findViewById(R.id.loginEmployerEmail);
    inputPassword = (EditText) findViewById(R.id.loginEmployerPassword);
    btnLoginEmployer = (Button) findViewById(R.id.btnLoginEmployer);
    btnLinkToEmployerRegisterScreen = (Button) findViewById(R.id.btnLinkToEmployerRegisterScreen);
    loginErrorMsg = (TextView) findViewById(R.id.login_error);
    forgotPassword = (TextView) findViewById(R.id.link_to_forgetPassword);

    // Login button Click Event
    btnLoginEmployer.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {
            // Checking for server respond
                new LoginEmployer().execute();
            }
        }
    });

    // Link to Register Screen
    btnLinkToEmployerRegisterScreen
            .setOnClickListener(new View.OnClickListener() {

                public void onClick(View view) {
                    Intent i = new Intent(getApplicationContext(),
                            RegisterEmployerActivity.class);
                    startActivity(i);
                    finish();
                }
            });

    // Link to forgot password link
    forgotPassword.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            // Switching to forgot password screen
            Intent i = new Intent(getApplicationContext(),
                    ForgotPasswordEmployerActivity.class);
            startActivity(i);
        }
    });
}

// Background ASYNC Task to login by making HTTP Request
class LoginEmployer extends AsyncTask<String, String, String> {

    // Before starting background thread Show Progress Dialog
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(LoginEmployerActivity.this);
        pDialog.setMessage("Authenticating...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        pDialog.show();
    }

    // Checking login in background
    protected String doInBackground(String... params) {
        runOnUiThread(new Runnable() {
            public void run() {

                String email = inputEmail.getText().toString();
                String password = inputPassword.getText().toString();
                EmployerFunctions employerFunctions = new EmployerFunctions();
                JSONObject json = employerFunctions.loginUser(email,
                        password);

                // check for login response
                try {
                    if (json.getString(KEY_SUCCESS) != null) {
                        loginErrorMsg.setText("");
                        String res = json.getString(KEY_SUCCESS);
                        if (Integer.parseInt(res) == 1) {
                            // user successfully logged in
                            // Store user details in SQLite Database
                            DatabaseHandlerEmployer dbe = new DatabaseHandlerEmployer(
                                    getApplicationContext());
                            JSONObject json_user = json
                                    .getJSONObject("user");

                            // Clear all previous data in database
                            employerFunctions
                                    .logoutUser(getApplicationContext());
                            dbe.addUser(
                                    json_user.getString(KEY_NAME),
                                    //json_user.getString(KEY_CNAME),
                                    json_user.getString(KEY_EMAIL),
                                    json.getString(KEY_UID),
                                    json_user.getString(KEY_CREATED_AT));
                            // Launch Employer homePage Screen
                            Intent homepage = new Intent(
                                    getApplicationContext(),
                                    HomepageEmployerActivity.class);

                            // Close all views before launching Employer
                            // homePage
                            homepage.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(homepage);

                            // Close Login Screen
                            finish();
                        } else {
                            // Error in login
                            loginErrorMsg
                                    .setText("Invalid username/password");
                        }
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
        return null;
    }

    // After completing background task Dismiss the progress dialog
    protected void onPostExecute(String file_url) {
        // dismiss the dialog once done
        pDialog.dismiss();
    }
}

}

  • 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-10T15:33:36+00:00Added an answer on June 10, 2026 at 3:33 pm

    Make sure that your searchBarEmployer has been initialised and referenced properly.

    EditText searchBarEmployer ; // outside onCreate, global to class
    

    Inside onCreate(),

    searchBarEmployer = (EditText)findViewById(R.id.editTextIdInXML);
    

    Also,

    @Override
    protected void onDestroy() {
        searchBarEmployer.removeTextChangedListener(filterTextWatcher);
        super.onDestroy();
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here friends. after i destroyed service in android still method call which i put
Created .NET WCF service, tested it - works. Generated schemas from Data and service
Created Private Key & Self signed certficate in a Key Store keytool -genkey -alias
Created an OpenGraph action and object. Trying to submit my action. When I click
I created a python server on port 8000 using python -m SimpleHTTPServer . When
I created cookie with server side code (c#) and it was shown in chrome
I created a JButton which has an image set as an icon representing the
I created a following class within a namespace Global namespace Global { public static
I created a new product type and everything works except the indexing of the
I created a PHP Drop Down which is populated from a MySql Database and

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.