I make an Android application for download a variable from my webserver
(use AsyncTask) and then send it to bluetooth.I make it with loop
(handler,postdelayed).I make a receive function from bluetooth and display
the insert new data temperature.I know how i upload i make a class and work
in another apk.How combine download and upload together?I test it but no
work...Need close inputstream,outputstream first?
public void run()
{
DownloadWebPageTask task = new DownloadWebPageTask();
task.execute(new String[] { strValue });
beginListenForData();//Receive data from bluetooth
// upload();//My problem is there....
if(work){ handler.postDelayed(this, 30000);}//Refresh page time
}
};
public void upload(){
//t = Integer.parseInt(data);
SimpleHttpPut.main(urlt,t);//Upload data class
}
public class SimpleHttpPut {
public static void main(String urlt,int t) {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(urlt);
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("temp",String.valueOf(t)));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new
InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en