Passing values from PHP to android

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Passing values from PHP to android

Postby prazannag » Sat Feb 06, 2010 4:12 pm

Hello There,
I want to do some process in PHP, after that i need to return those results to my android application. Can anyone help me to do.

Thanks & Regards,
Praz
Praz
User avatar
prazannag
Junior Developer
Junior Developer
 
Posts: 10
Joined: Fri Feb 05, 2010 7:34 pm
Location: India

Top

Postby mitutitu » Tue Feb 09, 2010 6:37 am

Hi prazannag, you can do such type of thing. You can use HTTPGET or HTTPPOST methods to do this thing on your android. All you need to do from your PHP side is to echo the data what you wanna grab from your android side via those methods. If you can more specific on your problem I can give you the proper solution right away.

Have fun :)

thanks,
mitu
User avatar
mitutitu
Senior Developer
Senior Developer
 
Posts: 113
Joined: Tue Jun 09, 2009 7:40 am
Location: St. John's, NL, Canada

Postby prazannag » Fri Feb 12, 2010 3:36 am

Is it possible to pass the table of contents on the same echo statement. Because i want to send the bulk of values.
Thank You.
Praz
User avatar
prazannag
Junior Developer
Junior Developer
 
Posts: 10
Joined: Fri Feb 05, 2010 7:34 pm
Location: India

Postby mitutitu » Fri Feb 12, 2010 5:16 am

Hi Praz,

yes you can echo a huge amount of data including whatever you want to echo.

thanks,
mitu
Android is awesome!
User avatar
mitutitu
Senior Developer
Senior Developer
 
Posts: 113
Joined: Tue Jun 09, 2009 7:40 am
Location: St. John's, NL, Canada

Postby prazannag » Tue Feb 23, 2010 9:19 am

Hi mitutitu,

Still i have the error, can u please check the code.

package com.org.WebTest;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class WebTest extends Activity {
/** Called when the activity is first created. */

private static final String SOAP_ACTION = "HelloYou";
private static final String METHOD_NAME = "getHello";
private static final String NAMESPACE = "urn:HelloYou";
private static final String URL = "http://127.0.0.1/mypro/services.php";



private Object resultsRequestSOAP = null;

@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
TextView tv = new TextView(this);
setContentView(R.layout.main);
// final TextView ot=(TextView)findViewById(R.id.tvv);

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);


//SoapObject
request.addProperty("firstname", "prasanna");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);


HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
{
androidHttpTransport.call(SOAP_ACTION, envelope);
resultsRequestSOAP = envelope.getResponse();
String[] results = (String[]) resultsRequestSOAP;
tv.setText( results[0].toString());


}
catch (Exception aE)
{
aE.printStackTrace ();
tv.setText(aE.toString());
}
}
-----
my PHP code is :

<?php
echo "POSTed data: '".$_POST['firstname']."'";
?>
-------
Praz
User avatar
prazannag
Junior Developer
Junior Developer
 
Posts: 10
Joined: Fri Feb 05, 2010 7:34 pm
Location: India

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests