// Executes UNIX command.
  private String exec(String command) {
    try {
      if (D) Log.d(TAG, "Exec command: " + command);
      Process process = Runtime.getRuntime().exec(command);
      BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
      BufferedReader errreader =
          new BufferedReader(new InputStreamReader(process.getErrorStream()));
      int read;
      char[] buffer = new char[4096];
      StringBuffer output = new StringBuffer();
      while ((read = reader.read(buffer)) > 0) {
        output.append(buffer, 0, read);
      }
      while ((read = errreader.read(buffer)) > 0) {
        output.append(buffer, 0, read);
      }
      errreader.close();
      process.waitFor();
      if (D) Log.d(TAG, output.toString());

      return output.toString();
    } catch (IOException e) {
      throw new RuntimeException(e);
    } catch (InterruptedException e) {
      throw new RuntimeException(e);
    }
  }
Example #2
0
  private void goToShowMsg(ShowMessageFromWX.Req showReq) {
    WXMediaMessage wxMsg = showReq.message;
    WXAppExtendObject obj = (WXAppExtendObject) wxMsg.mediaObject;

    StringBuffer msg = new StringBuffer(); // 组织一个待显示的消息内容
    msg.append("description: ");
    msg.append(wxMsg.description);
    msg.append("\n");
    msg.append("extInfo: ");
    msg.append(obj.extInfo);
    msg.append("\n");
    msg.append("filePath: ");
    msg.append(obj.filePath);

    Intent intent = new Intent(this, ShowFromWXActivity.class);
    intent.putExtra(net.sourceforge.simcpux.Constants.ShowMsgActivity.STitle, wxMsg.title);
    intent.putExtra(net.sourceforge.simcpux.Constants.ShowMsgActivity.SMessage, msg.toString());
    intent.putExtra(net.sourceforge.simcpux.Constants.ShowMsgActivity.BAThumbData, wxMsg.thumbData);
    startActivity(intent);
    // finish();
  }