用数据线连接手机,使用java程序控制手机发短信,打电话

来源:互联网 发布:linux ntp remote = 编辑:程序博客网 时间:2024/05/29 07:36
package com.zlp.dao;

import java.io.IOException;

public class Tests {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        try {
            Runtime.getRuntime().exec("F:\\android\\androidApp\\platform-tools\\adb.exe");//android中的adb.exe
            // Runtime.getRuntime().exec("cmd.exe /c start call tree /f");
//             Runtime.getRuntime().exec("cmd.exe  /c  notepad d:\\1234.txt");
            String cmds="cmd.exe  /c adb shell service call phone 2 s16 \"10086\" ";
            System.out.println(cmds);
            Runtime.getRuntime().exec(cmds);
            String cmd="cmd.exe  /c adb shell am start -a android.intent.action.SENDTO -d sms:10086 --es sms_body 'hello' --ez exit_on_sent true";  

             Runtime.getRuntime().exec(cmd);
            String cmd2 = "cmd.exe  /c  adb shell input keyevent 66  adb shell input keyevent 22";
            Runtime.getRuntime().exec(cmd2);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}



将android自带的

0 0
原创粉丝点击