Some people vote down after seeing these kinds of question. So if anyone votedown please tell the reason so that I may improve.
I am learning Android and I started studying webservices.
I used this php code
<?php
echo "hello abhi how are you";
?>
and this code in the Activity class of android application
public class MainActivity extends Activity {
BufferedReader in = null;
TextView tv1;
HttpClient httpclient;
HttpPost httppost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv1 = (TextView) findViewById(R.id.tv1);
httpclient = new DefaultHttpClient();
httppost = new HttpPost("http://10.0.2.2/devilabhi/a.php");
new getresult().execute();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public class getresult extends AsyncTask<Void, Void, Void>{
String result = null;
@Override
protected Void doInBackground(Void... arg0) {
// TODO Auto-generated method stub
try {
HttpResponse response = httpclient.execute(httppost);
result = EntityUtils.toString(response.getEntity());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e("Exception", e.toString());
}
return null;
}
@Override
protected void onPostExecute(Void result1) {
// TODO Auto-generated method stub
super.onPostExecute(result1);
tv1.setText(result);
Log.i("My Response :: ", result);
}
}
}
and I got output as
Now next step I want to learn is how to save name and email or anything else in database on server and how to retrieve that or I must study something else first so that I may understand this thing easily I searched regarding this and I got the link but there is no php code so I may not try this code
Is there any website, link or any example for us beginners to study and learn webservices.
Your suggestions and answers and very valuable for me and beginners like me. Thanks in Advance