顯示具有 Android 標籤的文章。 顯示所有文章
顯示具有 Android 標籤的文章。 顯示所有文章

2013年3月8日 星期五

Conversion to Dalvik format failed with error 1

From Evernote:

Conversion to Dalvik format failed with error 1

Conversion to Dalvik format failed with error 1

遇到這個錯誤可以檢查一下自已libs裡的jar是否有衝突。

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年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();

}