如何在adb shell命令中获取最后一条SMS?

问题描述 投票:0回答:1

我想将连接的android设备上的最新传入短信获取为字符串值。

c# adb
1个回答
0
投票

您可以使用Process.StandardOutput访问通过调用adb.exe返回的值

public static void Connect()
{
    Process process = new Process();
    ProcessStartInfo info = new ProcessStartInfo();

    info.WindowStyle = ProcessWindowStyle.Hidden;
    info.CreateNoWindow = true;
    info.UseShellExecute = false;
    info.RedirectStandardOutput = true;

    info.FileName = "adb/adb.exe";
    info.Arguments = "shell svc data enable";

    process.StartInfo = info;
    process.Start();
    // Synchronously read the standard output of the spawned process. 
    StreamReader reader = process.StandardOutput;
    string output = reader.ReadToEnd();
    // now the response is saved in the output variable and you can process it further.
}
© www.soinside.com 2019 - 2024. All rights reserved.