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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:11:18+00:00 2026-06-13T08:11:18+00:00

I’m building an application in which I need to bring auto suggestion using autocompletetextview,

  • 0

I’m building an application in which I need to bring auto suggestion using autocompletetextview, whenever the user types anything.

Here is my code:

public List<String> suggest;

HttpURLConnection con = null;
            String newText = key[0];
            newText = newText.trim();
            newText = newText.replace(" ", "+");
            try {
                // Check if task has been interrupted
                if (Thread.interrupted())
                    throw new InterruptedException();
                // Build RESTful query for Google API
                // String q = URLEncoder.encode(original, "UTF-8");
                URL url = new URL(
                        "http://google.com/complete/search?output=toolbar&q="
                                + newText);
                con = (HttpURLConnection) url.openConnection();
                con.setReadTimeout(10000 /* milliseconds */);
                con.setConnectTimeout(15000 /* milliseconds */);
                con.setRequestMethod("GET");
                // con.addRequestProperty("Referer",
                // "http://www.pragprog.com/titles/eband3/hello-android");
                con.setDoInput(true);
                // Start the query
                con.connect();

                // Check if task has been interrupted
                if (Thread.interrupted())
                    throw new InterruptedException();
                // Read results from the query
                XmlPullParser parser = Xml.newPullParser();
                parser.setInput(con.getInputStream(), null);
                int eventType = parser.getEventType();
                while (eventType != XmlPullParser.END_DOCUMENT) {
                    String name = parser.getName();
                    if (eventType == XmlPullParser.START_TAG
                            && name.equalsIgnoreCase("suggestion")) {
                        for (int i = 0; i < parser.getAttributeCount(); i++) {
                            if (parser.getAttributeName(i)
                                    .equalsIgnoreCase("data")) {
                                suggest.add(parser.getAttributeValue(i));
                            }
                        }
                    }
                    eventType = parser.next();
                }

                // Check if task has been interrupted
                if (Thread.interrupted())
                    throw new InterruptedException();

            } catch (Exception e) {

            }

This is giving me log error as:

10-22 11:36:46.531: E/AndroidRuntime(22291): FATAL EXCEPTION: main
10-22 11:36:46.531: E/AndroidRuntime(22291): java.lang.NullPointerException
10-22 11:36:46.531: E/AndroidRuntime(22291):    at android.widget.ArrayAdapter.getCount(ArrayAdapter.java:291)
10-22 11:36:46.531: E/AndroidRuntime(22291):    at android.widget.AutoCompleteTextView$PopupDataSetObserver$1.run(AutoCompleteTextView.java:1670)
10-22 11:36:46.531: E/AndroidRuntime(22291):    at android.os.Handler.handleCallback(Handler.java:587)
10-22 11:36:46.531: E/AndroidRuntime(22291):    at android.os.Handler.dispatchMessage(Handler.java:92)
10-22 11:36:46.531: E/AndroidRuntime(22291):    at android.os.Looper.loop(Looper.java:130)
10-22 11:36:46.531: E/AndroidRuntime(22291):    at  android.app.ActivityThread.main(ActivityThread.java:3689)
10-22 11:36:46.531: E/AndroidRuntime(22291):    at java.lang.reflect.Method.invokeNative(Native Method)
10-22 11:36:46.531: E/AndroidRuntime(22291):    at java.lang.reflect.Method.invoke(Method.java:507)
10-22 11:36:46.531: E/AndroidRuntime(22291):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
10-22 11:36:46.531: E/AndroidRuntime(22291):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
10-22 11:36:46.531: E/AndroidRuntime(22291):    at dalvik.system.NativeStart.main(Native Method)
10-22 11:36:46.539: E/(1459): Dumpstate > /data/log/dumpstate_app_error

Can’t figure out what am I doing wrong. Please point me towards that.

  • 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-13T08:11:19+00:00Added an answer on June 13, 2026 at 8:11 am

    Thank You, but I resolved my issue. Instead of using XML I used JSON parsing and this is much more faster than XML parsing. I have used wikisuggest api and parsed it to show the suggestions as the user types. Sorry to say but I think no bounty now.

    By the way thank you all for giving it attention and trying to solve my problem, I really appreciate all.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I need to clean up various Word 'smart' characters in user input, including but
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 am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... 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.