Exec And Wait : System « Development « Android






Exec And Wait

    
/*
    flashrec - a program to flash the recovery partition on Android devices.
    Copyright (C) 2009  Christopher Lais

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

//package org.zenthought.flashrec;

import java.io.IOException;

import android.util.Log;

class Util {
    public static boolean execAndWait(String[] args) {
        try {
            Process p = Runtime.getRuntime().exec(args);
            while (true) try {
                int code = p.waitFor();
                if (code != 0) { Log.d("FlashRec", String.format("%s exited with code %d", args[0], code)); return false; }
                return true;
            } catch (InterruptedException e) {
                e.printStackTrace();
                continue;
            }
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
    }
}

   
    
    
    
  








Related examples in the same category

1.Run System Command
2.Get Process ID with shell command and read by Java code
3.Get App Name
4.Check For Installed App
5.Get Api Level