Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class mainActivity extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- Button bLightOn = (Button) findViewById(R.id.button1);
- bLightOn.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- // TODO Auto-generated method stub
- Process process = null;
- DataOutputStream os = null;
- try {
- process = Runtime.getRuntime().exec("su");
- os = new DataOutputStream(process.getOutputStream());
- os.writeBytes("echo 0 > /sys/class/gpio/gpio168/value");
- os.writeBytes("cat /sys/class/gpio/gpio168/value \n");
- os.writeBytes("exit\n");
- os.flush();
- process.waitFor();
- } catch (Exception e) {
- return;
- }
- finally {
- try {
- if (os != null) {
- os.close();
- }
- process.destroy();
- } catch (Exception e) {
- // Be Happy :)
- }
- }
- }
- });
Add Comment
Please, Sign In to add comment