2012年9月12日 星期三

Android delvikvm GC所代表的意思

/* Not enough space for an "ordinary" Object to be allocated. */
GC_FOR_MALLOC,
/* Automatic GC triggered by exceeding a heap occupancy threshold. */
GC_CONCURRENT,
/* Explicit GC via Runtime.gc(), VMRuntime.gc(), or SIGUSR1. */
GC_EXPLICIT,
/* GC to try to reduce heap footprint to allow more non-GC'ed memory. */
GC_EXTERNAL_ALLOC,
/* GC to dump heap contents to a file, only used under WITH_HPROF */
GC_HPROF_DUMP_HEAP

2012年9月1日 星期六

Mac OS X 安裝Ant

1.下載Ant
http://ant.apache.org/

2.解壓縮到/usr/local
unzip apache-ant-1.8.4-bin.zip /usr/local

3.建立連結
ln -s apache-ant-1.8.4-bin ant

4.設定環境變數
cd
vim .bash_profile


export ANT_HOME=/usr/local/ant                                            
export PATH=${PATH}:${ANT_HOME}/bin

5.重開終端機
ant -version

顯示如下:
Apache Ant(TM) version 1.8.4 compiled on May 22 2012

2012年1月18日 星期三

HttpClient 檔案上傳 + 參數


如果想在HttpClient上使用上傳檔案加上參數,使用MultipartEntity物件。

使用方式如下:

HttpPost post = new HttpPost(http://localhost/upload.php);

MultipartEntity reqEntity = new MultipartEntity(
       HttpMultipartMode.BROWSER_COMPATIBLE);

FileBody bin = new FileBody(new File(/mnt/sdcard/test.zip));

Charset chars = Charset.forName("UTF-8");

try {

    reqEntity.addPart("參數名稱", new StringBody("參數內容",chars));

    reqEntity.addPart("FileUpload1", bin );

    post.setEntity(reqEntity);

    HttpResponse response = httpClient.execute(post);

    HttpEntity entity = response.getEntity();

    if(entity == null){
        return ;
    }

    InputStream is = entity.getContent();

    BufferedReader br = new BufferedReader(new InputStreamReader(is,"utf-8"));

    String str = br.readLine();


    //印出回傳結果
    System.out.println(str);
}catch (Exception e) {


    e.printStackTrace();

}