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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:24:22+00:00 2026-05-29T11:24:22+00:00

I’m newbie. Now i face this kind of question. I am using the CustomHttpClient

  • 0

I’m newbie. Now i face this kind of question.

I am using the CustomHttpClient to connect to local server. I was wondering how the a spinner display value from the php and how it would be work? I have no idea on the java code? Can suggest some of the example or site for me ?

  • 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-29T11:24:23+00:00Added an answer on May 29, 2026 at 11:24 am

    This is an approach I used. Note I’ve included things such as webpage address(WebPage) here so it’s easier for you to see what is going on. I would advice against placing it here because if the host address changes you’ll have to go back and change this in your code.

    Android side:

    /**
     * Class for receiving data from server.
     * @author Jonathan B
     *
     */
    public class ReceiveData 
    {
    //FILL IN webPage with link to the All folder on your server.
    private String webPage = "http://www.example.com/Receive/";
    
    //File name of the PHP file that is to be used by the method.
    private String fileName; 
    String delims = " ,\t\n\"\\;{}[]\\()<>&^%$@!+/*~=";
    
    /**
     * Constructor.
     */
    public ReceiveData()
    {
    
    }
    
    /**
     * Pass arguments to PHP file. Then receive data from PHP file.
     * @param file - PHP file in question
     * @param data - Arguments to pass to PHP file.
     * @return output - The data received from server.
     */
    private ArrayList<String> receiveData(String file, ArrayList<NameValuePair> data)
    {
        InputStream is = null;
        ArrayList<String> output = new ArrayList<String>();
        String line = null;
    
        //Connect and obtain data.
        try
        {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(webPage+file);
            httppost.setEntity(new UrlEncodedFormEntity(data));
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();
    
        }
        catch(Exception e)
        {
            Log.e("log_tag", "Error in http connection "+e.toString());
        }
    
        //Parse data into ArrayList and return.
        try
        {
            BufferedReader reader = 
                new BufferedReader(new InputStreamReader(is,"iso-8859-1"));
    
            while ((line = reader.readLine()) != null) 
            {
                //Parse data into tokens and removing unimportant tokens.
                StringTokenizer st = new StringTokenizer(line, delims, false);
    
                while(st.hasMoreTokens())
                {
                    String token = st.nextToken();
                    output.add(token);
                }
            }
    
            is.close();
            //Log output of data in LogCat.
            Log.d("DATA","DATA:"+output);
    
        }
        catch(Exception e)
        {
            Log.e("log_tag", "Error converting result "+e.toString());
        }
        return output;
    }
    
    /**
     * Gets all  data from GetAllData.php
     * @return output - ArrayList containing  data.
     */
    public ArrayList<String> getData(String row)
    {
        fileName = "GetData.php";
    
        //Add arguments to arrayList<NameValuePairs> so we can encode the data and send it on.
        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
        nameValuePairs.add(new BasicNameValuePair("row", row));
    
        ArrayList<String> output = this.receiveData(fileName, nameValuePairs);
        return output;
    }
    

    Now for the php side of things I had a file in the receive foldeer called GetData.php which looks like this:

    <?php
    /*
     * What this file does is it:
     * 1) Creates connection to database.
     * 2) Gets data from database.
     * 3) Encodes data to JSON. So this data can then be used by Android Application.
     * 4) Close database connection.
     */
    require_once 'Connection.php';
    require_once 'ReceiveAPI.php';
    
    $server = new Connection();
    $receive = new ReceiveAPI();
    
    //Retrieve information.
    $row = $_POST['row'];
    
    //Connect to database.
    $server->connectDB();
    $output = $receive->getAllData($row);
    print(json_encode($output));
    
    //Disconnect from database.
    $server->disconnectDB();
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
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
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't

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.