• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps sending request to remote php connected to database (search function)

jdgower15

Lurker
Aug 10, 2011
2
0
OK...I am very new to android development. I recently built an intranet for my company and have a need/want to access the information on the intranet through an android application. Mainly, this is a list of clients. I have used another program I found on the internet and modified it to get my list and I can do so using code like this:

Code:
JSONObject json = JSONfunctions.getJSONfromURL("http://www.websitehere.com/json.php?keyword=patel");

This successfully gets a list of clients via a mysql lookup and echo's that list as JSON...this all works fine, the problem I am having is defining that 'patel'...

I would like to add a text box where one would enter 'john' or 'patel' or whatever, click a button and the application searches and returns the results. Please keep in mind I am very new to all of this and I apologize. At this point I'm not even sure how to make my application wait until a button is clicked to run.

Thanks for any help you may be able to provide. I am very frustrated and would even send my current application (eclipse export) to someone to look at if you're willing.
 
OK...got it, somehow...

Basically, I changed the public void onCreate to public void whatever()...then i made a new onCreate which called the search box/button, once the button is clicked it calls to whatever() function to perform the search...whatever() in the below is actually startService()....

Code:
public class test extends ListActivity {
    /** Called when the activity is first created. */
	private EditText input;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listplaceholder);
        
        Button start = (Button)findViewById(R.id.startButton);
        
        start.setOnClickListener(new OnClickListener() {
        	public void onClick(View v){
        		startService();
        	}
        });
        
    }
    
    public void startService(){
        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
        EditText input = (EditText) findViewById(R.id.search_edit_text);
        JSONObject json = JSONfunctions.getJSONfromURL("http://www.website.com/json.php?keyword=" + input.getText().toString() + "");
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones