
	Process p;
	
	try 
	{
	    p = Runtime.getRuntime().exec(com);
		p.waitFor();
		
	}
	catch (IOException e) 
	{
			e.printStackTrace();
	}
	catch (InterruptedException e)
	{
			e.printStackTrace();
	}	
	
	
	///////////
	
	package com.mixtile.loftqgpio;

import android.util.Log;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
/**
 * Created by kurain on 7/13/15.
 */
public class GPIOCommonSu {
    private static final String TAG="GPIOSu";
    private int process_cmd(String cmd){
        Log.i(TAG, "process cmd: " + cmd);
        try {
            Process process = Runtime.getRuntime().exec("su");
            DataOutputStream dos = new DataOutputStream(process.getOutputStream());
            dos.writeBytes(cmd + "\n");
            dos.flush();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        return 0;
    }

    private int process_read(String cmd){
        try {
            Process process = Runtime.getRuntime().exec("su");
            DataOutputStream dos = new DataOutputStream(process.getOutputStream());
            dos.writeBytes(cmd + "\n");
            dos.flush();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        return 0;
    }

    public int export(int id){
        String cmd = "/system/bin/sh echo " + id + " > /sys/class/gpio/export";
        return process_cmd(cmd);
    }
    public int unexport(int id){
        String cmd = "/system/bin/sh echo " + id + " > /sys/class/gpio/unexport";
        return process_cmd(cmd);
    }

    public int enable_out(int id){
        String cmd = "/system/bin/sh echo out > " + " /sys/class/gpio/gpio" + id + "/direction";
        return process_cmd(cmd);
    }

    public int enable_in(int id){
        String cmd = "/system/bin/sh echo in > " + " /sys/class/gpio/gpio" + id + "/direction";
        return process_cmd(cmd);
    }

    public int read(int id){
        return 0;
    }

    public int write(int id, int bon){
        String cmd ="echo " + (0 == bon ? 0:1) + " > /sys/class/gpio/gpio" + id + "/value";
       
 return process_cmd(cmd);
    }
}

    Status API Training Shop Blog About Pricing 


	
	https://github.com/OLIMEX/OLINUXINO/tree/master/SOFTWARE/A20/ANDROID%20A20-OLINUXINO-TOOLS
	
	
	i2cdetect, i2cset, i2cget
	
	http://elinux.org/Interfacing_with_I2C_Devices
	
	
    dmesg | grep i2c : permet de visualiser les messages du noyau se rapportant au bus i2c,
    ls /dev/i2c* : cette commande permet de savoir si le bus i2c est bien accessible depuis “l’espace utilisateur” donc depuis vos programmes.

	un capteur de température DS1631,
	
	
    adresse 0x48 : capteur DS1631 dont les lignes d’adresses A2, A1 et A0 sont reliées à la masse. L’adresse de ce composant est donné dans la documentation : 0b1001A2A1A0 donc 0b1001000 donc en hexadécimal 0x48.
    adresse 0x68 : horloge RTC. Dans la documentation on trouve l’adresse suivante : 0b1101000 soit 0x68.

	import smbus
import time

# Remplacer 0 par 1 si nouveau Raspberry
bus = smbus.SMBus(0)
address = 0x12

print "Envoi de la valeur 3"
bus.write_byte(address, 3)
# Pause de 1 seconde pour laisser le temps au traitement de se faire
time.sleep(1)
reponse = bus.read_byte(address)
print "La reponse de l'arduino : ", reponse

http://connect.ed-diamond.com/GNU-Linux-Magazine/GLMFHS-075/Communiquer-en-i2c-avec-un-capteur-de-temperature

TMP02


http://lindev.fr/index.php?tag/capteur%20temp%C3%A9rature    super .....

http://diyhacking.com/raspberry-pi-robot/

http://jmdefais.pagesperso-orange.fr/techn_jm/robot/robot_pi/robot_pi.htm

http://www.java2s.com/Open-Source/Android_Free_Code/

///////////////////////
HttpClient 

HttpURLConnection 

public static String excutePost(String targetURL, String urlParameters) {
  HttpURLConnection connection = null;  
  try {
    //Create connection
    URL url = new URL(targetURL);
    connection = (HttpURLConnection)url.openConnection();
    connection.setRequestMethod("POST");
    connection.setRequestProperty("Content-Type", 
        "application/x-www-form-urlencoded");

    connection.setRequestProperty("Content-Length", 
        Integer.toString(urlParameters.getBytes().length));
    connection.setRequestProperty("Content-Language", "en-US");  

    connection.setUseCaches(false);
    connection.setDoOutput(true);

    //Send request
    DataOutputStream wr = new DataOutputStream (
        connection.getOutputStream());
    wr.writeBytes(urlParameters);
    wr.close();

    //Get Response  
    InputStream is = connection.getInputStream();
    BufferedReader rd = new BufferedReader(new InputStreamReader(is));
    StringBuilder response = new StringBuilder(); // or StringBuffer if not Java 5+ 
    String line;
    while((line = rd.readLine()) != null) {
      response.append(line);
      response.append('\r');
    }
    rd.close();
    return response.toString();
  } catch (Exception e) {
    e.printStackTrace();
    return null;
  } finally {
    if(connection != null) {
      connection.disconnect(); 
    }
  }
}


import java.net.*;
import java.io.*;

public class URLConnectionReader {
    public static void main(String[] args) throws Exception {
        URL yahoo = new URL("http://www.yahoo.com/");
        URLConnection yc = yahoo.openConnection();
        BufferedReader in = new BufferedReader(
                                new InputStreamReader(
                                yc.getInputStream()));
        String inputLine;

        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
    }
}




import java.io.File;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.util.EntityUtils;


public class PostFile {
  public static void main(String[] args) throws Exception {
    HttpClient httpclient = new DefaultHttpClient();
    httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);

    HttpPost httppost = new HttpPost("http://localhost:9001/upload.php");
    File file = new File("c:/TRASH/zaba_1.jpg");

    MultipartEntity mpEntity = new MultipartEntity();
    ContentBody cbFile = new FileBody(file, "image/jpeg");
    mpEntity.addPart("userfile", cbFile);


    httppost.setEntity(mpEntity);
    System.out.println("executing request " + httppost.getRequestLine());
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity resEntity = response.getEntity();

    System.out.println(response.getStatusLine());
    if (resEntity != null) {
      System.out.println(EntityUtils.toString(resEntity));
    }
    if (resEntity != null) {
      resEntity.consumeContent();
    }

    httpclient.getConnectionManager().shutdown();
  }
}




 Firstly, you would need to download a bunch of libraries. Download these jar files and add them to your java build path as external jars. Right Click on project --> properties --> Java Build path --> libraies --> add external jars.
apache-mime4j-0.3.jar
commons-io-1.4.jar
commons-logging-1.1.1.jar
httpclient-4.1-alpha1.jar
httpcore-4.1-alpha1.jar
httpmime-4.0-alpha4.jar


import java.io.File;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.util.EntityUtils;
 
 
public class UploadFile {
  public static void upload() throws Exception {
 
        String userHome=System.getProperty("user.home");
        HttpClient httpclient = new DefaultHttpClient();
        httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
        HttpPost httppost = new HttpPost("http://www.xxx.xxxx.xxx/Projects/test/upload.php");
        File file = new File(userHome+"/Hello.txt");
        MultipartEntity mpEntity = new MultipartEntity();
        ContentBody contentFile = new FileBody(file);
        mpEntity.addPart("userfile", contentFile);
        httppost.setEntity(mpEntity);
        System.out.println("executing request " + httppost.getRequestLine());
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity(); 
 
        if(!(response.getStatusLine().toString()).equals("HTTP/1.1 200 OK")){
            // Successfully Uploaded
        }
        else{
            // Did not upload. Add your logic here. Maybe you want to retry.
        }
        System.out.println(response.getStatusLine());
        if (resEntity != null) {
            System.out.println(EntityUtils.toString(resEntity));
        }
        if (resEntity != null) {
            resEntity.consumeContent();
        }
        httpclient.getConnectionManager().shutdown();
    }
 
  public static void main(String[] args)
  {
      try {
        UploadFile.upload();
    } catch (Exception e) {
 
        e.printStackTrace();
    }
  }
}


<!--?php
$uploads_dir = '/home/veeru/Desktop/veeruUploads';
if(is_uploaded_file($_FILES['userfile']['tmp_name'])) {
echo  "File ".  $_FILES['userfile']['name']  ." uploaded successfully to 
$uploads_dir/$dest.\n";
$dest=  $_FILES['userfile'] ['name'];
move_uploaded_file ($_FILES['userfile'] ['tmp_name'], "$uploads_dir/$dest");
} else {
echo "Possible file upload attack: ";
echo "filename '". $_FILES['userfile']['tmp_name'] . "'.";
print_r($_FILES);
}
?-->


http://mobiledevtuts.com/android/android-http-with-asynctask-example/

http://hc.apache.org/downloads.cgi

https://www.codeofaninja.com/2013/04/android-http-client.html

http://dsilvera.developpez.com/tutoriels/android/creer-page-login-verifier-identification-base-donnees-script-php/


https://github.com/daviduxotto/APP_php/blob/master/app/src/main/java/dawareestudio/app_php/HttpHandler.java

https://github.com/PeopleVitry/Social-Network-Android-Version/blob/master/GlobalProject/src/com/formation/projetglobal/Alarme.java

Sending HTTP POST Request In Java

http://androidexample.com/How_To_Make_HTTP_Get_Request_To_Server_-_Android_Example%20/index.php?view=article_discription&aid=63&aaid=88
	