Android 7.0システム変更時間

977 ワード

以前は4.0以前に使用したフォーマットの変更が多かったのですが、7.0以降はフォーマットが変更されていますので、adbコマンドでデバッグすることをお勧めします.できればコードを入れてもいいです.rootと権限の追加を覚えておいてください
/**
 *   Android  ,      
 * @param cmd    
 */
public static void execSuCmd(String cmd) {
    Process process = null;
    DataOutputStream os = null;
    DataInputStream is = null;
    try {
        process = Runtime.getRuntime().exec("su");
        os = new DataOutputStream(process.getOutputStream());
        os.writeBytes(cmd + "
"); os.writeBytes("exit
"); os.flush(); int aa = process.waitFor(); is = new DataInputStream(process.getInputStream()); byte[] buffer = new byte[is.available()]; is.read(buffer); String out = new String(buffer); } catch (Exception e) { e.printStackTrace(); } }
String curr_time = "092110202015.52";   //       
TimeUtils.execSuCmd("date " + curr_time);