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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:18:13+00:00 2026-05-27T07:18:13+00:00

I’m calling the object here. public class TestDetails extends ListActivity { protected TextView testNameText;

  • 0

I’m calling the object here.

public class TestDetails extends ListActivity {

    protected TextView testNameText;
    protected SQLiteDatabase db;
    protected TextView testvalueText;
    protected List<TestAction> actions;
    protected TestItemAdapter adapter;
    protected int testId;
    protected int categoryId;

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

    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.list_search: onSearchRequested();
            break;
        }
        return true;
    }
    //end of add options menu
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test_details);

     // Get the intent, verify the action and get the query
        db = (new DatabaseHelper(this)).getWritableDatabase();
        Intent intent1 = getIntent();
        SimpleSearch SSearch = new SimpleSearch();
        if (Intent.ACTION_SEARCH.equals(intent1.getAction())) {
          String query = intent1.getStringExtra(SearchManager.QUERY);
          SSearch.testSearch(query);
          }

        testId = getIntent().getIntExtra("EMPLOYEE_ID", 0);
        SQLiteDatabase db = (new DatabaseHelper(this)).getWritableDatabase();
        Cursor cursor = db.rawQuery("SELECT emp._id, emp.firstName, emp.lastName, emp.title, emp.officePhone, emp.cellPhone, emp.email, emp.managerId, mgr.firstName managerFirstName, mgr.lastName managerLastName FROM employee emp LEFT OUTER JOIN employee mgr ON emp.managerId = mgr._id WHERE emp._id = ?", 
                new String[]{""+testId});

        if (cursor.getCount() == 1)
        {
            cursor.moveToFirst();
            testNameText = (TextView) findViewById(R.id.employeeName);
            testNameText.setText(cursor.getString(cursor.getColumnIndex("firstName")) + " " + cursor.getString(cursor.getColumnIndex("lastName")));
            actions = new ArrayList<TestAction>();

            String officePhone = cursor.getString(cursor.getColumnIndex("officePhone"));
            if (officePhone != null) {
                actions.add(new TestAction("Call office", officePhone, TestAction.ACTION_CALL));
            }

            String cellPhone = cursor.getString(cursor.getColumnIndex("cellPhone"));
            if (cellPhone != null) {
                actions.add(new TestAction("Call mobile", cellPhone, TestAction.ACTION_CALL));
                actions.add(new TestAction("SMS", cellPhone, TestAction.ACTION_SMS));
            }

            String email = cursor.getString(cursor.getColumnIndex("email"));
            if (email != null) {
                actions.add(new TestAction("Email", email, TestAction.ACTION_EMAIL));
            }

            categoryId = cursor.getInt(cursor.getColumnIndex("managerId"));
            if (categoryId>0) {
                actions.add(new TestAction("View manager", cursor.getString(cursor.getColumnIndex("managerFirstName")) + " " + cursor.getString(cursor.getColumnIndex("managerLastName")), TestAction.ACTION_VIEW));
            }

            cursor = db.rawQuery("SELECT count(*) FROM employee WHERE managerId = ?", 
                    new String[]{""+testId});
            cursor.moveToFirst();
            int count = cursor.getInt(0);
            if (count>0) {
                actions.add(new TestAction("View direct reports", "(" + count + ")", TestAction.ACTION_REPORTS));
            }

            adapter = new TestItemAdapter();
            setListAdapter(adapter);
        }

    }

    class TestItemAdapter extends ArrayAdapter<TestAction> {
        TestItemAdapter() {
            super(TestDetails.this, R.layout.action_list_item, actions);
        }

        @Override
        public boolean areAllItemsEnabled() {
            return false;
        }
        public boolean isEnabled(int position) {
           return false;
        }
        public View getView(int position, View convertView, ViewGroup parent) {
            TestAction action = actions.get(position);
            LayoutInflater inflater = getLayoutInflater();
            View view = inflater.inflate(R.layout.action_list_item, parent, false);
            TextView label = (TextView) view.findViewById(R.id.label);
            label.setText(action.getLabel());
            TextView data = (TextView) view.findViewById(R.id.data);
            data.setText(action.getData());
            return view;
        }

    }

}

This is the class from which I’m calling the object.(part of the class)

public class SimpleSearch extends ListActivity {
    protected SQLiteDatabase db;
    protected Cursor cursor;
    protected ListAdapter adapter;
    protected String query;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        db = (new DatabaseHelper(this)).getWritableDatabase();
        // Get the intent, verify the action and get the query
        Intent intent = getIntent();
        if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
          String query = intent.getStringExtra(SearchManager.QUERY);
          testSearch(query);
          }
        else TestListAll();
        }

But I’m getting a force close on running the application. Stack trace shows the error to be in SSearch.testSearch(query); statement. What am I missing here?

Stack trace:

app_vercode:1
device_model:umts_jordan
build_version:1.11.18
condition:1
processName:com.simple.search
pid:3529
uid:10063
tag:null
shortMsg:java.lang.NullPointerException
longMsg:java.lang.NullPointerException: Unable to start activity ComponentInfo{com.simple.search/com.simple.search.TestDetails}: java.lang.NullPointerException
stackTrace:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.simple.search/com.simple.search.TestDetails}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1664)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1680)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3703)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.simple.search.SimpleSearch.testSearch(SimpleSearch.java:68)
at com.simple.search.TestDetails.onCreate(TestDetails.java:59)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1628)
... 11 more
  • 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-05-27T07:18:14+00:00Added an answer on May 27, 2026 at 7:18 am

    Most likely the line

    String query = intent1.getStringExtra(SearchManager.QUERY);
    

    Is assigning a null value to query – are you sure the correct extra is there? I usually get extras in this manner:

    public static final String TAG = "MyActivity";
    public static final String DATA_KEY = "DataKey";
    public static final String MY_CUSTOM_ACTION = "MyCustomSearchAction";
    
    public void onCreate(Bundle savedInstanceState) {
        Intent intent1 = getIntent();
        SimpleSearch SSearch = new SimpleSearch();
        if (intent1.getAction().equals(MY_CUSTOM_ACTION) 
              && intent1.hasExtra(SearchManager.QUERY)
              && intent.hasExtra(DATA_KEY)) {
            String query = intent1.getStringExtra(SearchManager.QUERY);
            DataObject data = intent1.getParcelableExtra(DATA_KEY);   
            if (query != null && data != null)
                SSearch.testSearch(query, data);
            else {
                //invalid query
               Log.d(TAG,"Activity started with invalid query data - closing");
               this.finish();
               return;
            }
        } else {
           //Invalid Intent
           Log.d(TAG,"Activity started with invalid intent - closing");
           this.finish();
           return;
        }
    }
    

    A data object can look like this:

    public class DataObject implements Parcelable {
    
        public String someData;
        public String someMoreData;
    
        @Override
        public int describeContents() {
            return 0;
    }
    
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(someData);
        dest.writeString(someMoreDate);
    }
    
    //Constructor for parceler
    public DataObject(Parcel src) {
        someData = src.readString();
        someMoreData = src.readString();
    }
    
    public static final Parcelable.Creator<DataObject> CREATOR = 
                    new Parcelable.Creator<DataObject>() {
    
        public DataObject createFromParcel(Parcel in) {
            return new DataObject(in);
        }
    
        public DataObject[] newArray(int size) {
            return new DataObject[size];
        }
    };
    

    }

    To start your activity just go:

    DataObject data = new DataObject();
    data.someData = "test";
    data.someMoreData = "test2";
    Intent intent = new Intnent(this, MyActivity.class);
    intent.setAction(MyActivity.MY_CUSTOM_ACTION);
    intent.putExtra(MyActivity.DATA_KEY,data);
    intent.putExtra(SearchManager.QUERY, "Query");
    startActivity(intent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
I am doing a simple coin flipping experiment for class that involves flipping a
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, 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.