給予Socket一個android日誌收集程式附用戶端調用DEMO

來源:互聯網
上載者:User

標籤:android   http   io   ar   os   使用   sp   java   strong   

來源:
解決手機用戶端即時跟蹤調試問題.

主要說明:
主要用於調試收集多終端相關日誌資訊作用. 現在僅限區域網路.使用外網青保證映射正確.
如.一個APP多個終端同時使用.測試問題的體現可以使用此軟體進行定位處理.
軟體服務端使用線程池可保證大資料量下的穩定性.理論上可接受任何給予socket的資訊互動程式.下面有已經被使用的JAVA用戶端代碼供大家參考.

JAVA用戶端DEMO代碼:

new SendPcLog(log).start();

package cn.sj.soft;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;import 
java.net.SocketTimeoutException;    
import java.net.URLEncoder;

/**

 * 發送記錄檔到PC 定位錯誤  android 
 * @author zw
*/

public class SendPcLog extends Thread {
private static String HOST = "192.168.1.88";
private static int PORT = 19730;
static String buffer = "";
static Socket socket = null;
    public String txt1;
    public SendPcLog(String str) {
  txt1 = android.os.Build.MODEL+":"+str;
 }

@Override
public void run() {

        //定義訊息
  try {
  //串連伺服器 並設定連線逾時為5秒
socket = new Socket();
socket.connect(new InetSocketAddress(HOST, PORT), 5000);
 //擷取輸入輸出資料流
OutputStream ou = socket.getOutputStream();
 //向伺服器發送資訊
  ou.write(URLEncoder.encode(txt1, "utf-8").getBytes());
  ou.flush();
  ou.close();
  socket.close();
} catch (SocketTimeoutException aa) {
// bundle.putString("msg", "伺服器串連失敗!請檢查網路是否開啟");

     } catch (IOException e) {
             e.printStackTrace();

         }

    }

} 

 

 

詳情: http://www.shijieweb.cn/post/1cc4ef53_40fc277

 

分類:世捷系列軟體原創作品

給予Socket一個android日誌收集程式附用戶端調用DEMO

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.