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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:50:37+00:00 2026-06-05T12:50:37+00:00

I am doing a search on Active.com using their API and currently my search

  • 0

I am doing a search on Active.com using their API and currently my search is getting stuck at this error : org.json.JSONException: End of input at character 0. I am a newbie,Any help is appreciated.

MainActivity

      private class SearchTask extends AsyncTask<String, Integer, String>
{
    ProgressDialog dialog;

        @Override
        protected void onPreExecute() {

            dialog = ProgressDialog.show(StayActiveActivity.this,"","Please Wait...");

            super.onPreExecute();
        }

        @Override
        protected String doInBackground(String... params) {
            try {
                String result = ActiveHelper.download(params [0]);
                return result;
            } catch (ApiException e) {
                e.printStackTrace();
                Log.e("alatta", "Problem making search request");
            }
            return "";
        }
        @Override
        protected void onPostExecute(String result) {

            try {
                JSONObject obj = new JSONObject(result);
                m_results = obj.getJSONArray("results");
                if (m_results == null || m_results.length() == 0)
                {
                    Toast.makeText(getApplicationContext(),
                            "No Results found for " + m_search_text.getText(), 
                            Toast.LENGTH_LONG).show();

                }
                else
                    m_search_results.setAdapter(new JSONAdapter(getApplicationContext()));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

private class JSONAdapter extends BaseAdapter
{
    public JSONAdapter(Context c){

    }

    public int getCount() 
    {
    return  m_results.length();
        }

    public Object getItem(int arg0){
        return null;
    }

    public long getItemId(int pos){
        return pos;

    }

    public View getView(int pos, View convertView, ViewGroup parent) {
        View tv;
        TextView t;

        if (convertView == null)
            tv = m_inflater.inflate (R.layout.item, parent, false);
        else
            tv = convertView;
        try {
            /* For each entry in the ListView, we need to populate 
             * its text and timestamp */
            t = (TextView) tv.findViewById(R.id.text);
            JSONObject obj = m_results.getJSONObject(pos);

            t.setText (obj.getString("event") + ": " + 
                        obj.getString("text"));

            t = (TextView) tv.findViewById(R.id.created_at);
            t.setText (obj.getString("created_at"));
        } catch (JSONException e) {

            Log.e("alatta", e.getMessage());
        }
        return tv;
    }

   }

ActiveHelper

 public class ActiveHelper {

private static final String ACTIVE_SEARCH = "http://api.amp.active.com/search?&v=json&api_key=rm4agnjv6k4m4tvpft95xvbn";
    private static final int HTTP_STATUS_OK = 200;
    private static byte[] buff = new byte[1024];



 public static class SearchException extends Exception {
        public SearchException (String msg)
        {
            super (msg);
        }

        public SearchException (String msg, Throwable thr)
        {
            super (msg, thr);
        }
 }
        protected static synchronized String download (String parm)
                throws SearchException
            {
                String url = ACTIVE_SEARCH+ parm;
                HttpClient client = new DefaultHttpClient();
                HttpGet request = new HttpGet(url);
                try {
                    HttpResponse response = client.execute(request);
                    StatusLine status = response.getStatusLine();
                    if (status.getStatusCode() != HTTP_STATUS_OK)
                        throw new SearchException("Invalid response from search.active.com" + 
                                status.toString());
                    HttpEntity entity = response.getEntity();
                    InputStream ist = entity.getContent();
                    ByteArrayOutputStream content = new ByteArrayOutputStream();
                    int readCount = 0;
                    while ((readCount = ist.read(buff)) != -1)
                        content.write(buff, 0, readCount);
                    return new String (content.toByteArray());
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new SearchException("Problem using the API", e);
                }
            }
        }

StackTrace

06-11 15:01:27.569: E/alatta(7698): Problem making search request
06-11 15:01:27.569: W/System.err(7698): org.json.JSONException: End of input at character 0 of 
06-11 15:01:27.569: W/System.err(7698):     at org.json.JSONTokener.syntaxError(JSONTokener.java:446)
06-11 15:01:27.569: W/System.err(7698):     at org.json.JSONTokener.nextValue(JSONTokener.java:93)
06-11 15:01:27.569: W/System.err(7698):     at org.json.JSONObject.<init>(JSONObject.java:154)
06-11 15:01:27.569: W/System.err(7698):     at org.json.JSONObject.<init>(JSONObject.java:171)
06-11 15:01:27.569: W/System.err(7698):     at my.stayactive.plan.StayActiveActivity$SearchTask.onPostExecute(StayActiveActivity.java:120)
06-11 15:01:27.569: W/System.err(7698):     at my.stayactive.plan.StayActiveActivity$SearchTask.onPostExecute(StayActiveActivity.java:1)
06-11 15:01:27.569: W/System.err(7698):     at android.os.AsyncTask.finish(AsyncTask.java:417)
06-11 15:01:27.569: W/System.err(7698):     at android.os.AsyncTask.access$300(AsyncTask.java:127)
06-11 15:01:27.579: W/System.err(7698):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
06-11 15:01:27.579: W/System.err(7698):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-11 15:01:27.579: W/System.err(7698):     at android.os.Looper.loop(Looper.java:150)
06-11 15:01:27.579: W/System.err(7698):     at android.app.ActivityThread.main(ActivityThread.java:4293)
06-11 15:01:27.579: W/System.err(7698):     at java.lang.reflect.Method.invokeNative(Native Method)
06-11 15:01:27.579: W/System.err(7698):     at java.lang.reflect.Method.invoke(Method.java:507)
06-11 15:01:27.579: W/System.err(7698):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
06-11 15:01:27.579: W/System.err(7698):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
06-11 15:01:27.579: W/System.err(7698):     at dalvik.system.NativeStart.main(Native Method)
  • 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-05T12:50:39+00:00Added an answer on June 5, 2026 at 12:50 pm

    In onPostExecute(...) I think you need to use _results for the name of the JSONArray and not results…

    m_results = obj.getJSONArray("results"); // Change to "_results"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a doubt with Google API URL. Currently I am doing search engine
I am doing: html = new WebClient().DownloadString( http://www.google.com/search?sourceid=chrome&ie=UTF-8&q= + biocompany); and i am getting
How do I search and replace whole words using sed? Doing sed -i 's/[oldtext]/[newtext]/g'
Doing a search using django-sphinx gives me results._sphinx that says there were 68 results,
Doing a search around I've found this kind of question being asked in the
When doing a search in active record I'm looking for record's that do not
I am doing this search engine that should only search my content, but in
Im doing a search where the POST is: sok3 = 0,2,6 I would then
After doing a long search on stackoverflow i didn't find any one talked about
After doing a light search on the Lazarus site I've come to the conclusion

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.