---
title: "开发中遇到的错误总结   ---断点记录"
author: "zengyan2012"
date: "2013-01-04T18:13:30Z"
tags: []
categories: ["移动开发"]
slug: "untitled"
draft: false
lastmod: "2013-01-15T15:23:20Z"
id: 1759872
url: "https://zengyan2012.iteye.com/blog/1759872"
---

**java.net.unknownhostException**

1：  没有网络访问权限。

2：手机网络状态是：cmwap,要改成 cmnet模式。（别人有详细的说明：[http://www.cnblogs.com/rockdean/articles/2439030.html](http://www.cnblogs.com/rockdean/articles/2439030.html) ）

 

 

**2.判断一个字符串是不是以/n/r（/n:换行，/r:空格）结尾的**

    1：把字符串转换成byte数组。

    2： 判断byte字符是不是等于/n和/r的acsii码值    /n： 13  /r ：10

 

**3:   华为C8812E背夹的条码返回值处理。(背夹返回值不是把条码的所有内容一次性返回，而是会多次返回值的操作)**

    ArrayList&lt;Byte&gt; tempList = new ArrayList&lt;Byte&gt;();

 private final Handler mHandler = new Handler() {  
        @Override  
        public void handleMessage(Message msg) {  
            switch (msg.what) {  
            case 1:  
                byte\[] bytes = (byte\[]) msg.obj;

                for (byte b : bytes) {  
                    tempList.add(b);  
                }

                strBuffer.append(new String(bytes));  
                mMailNumberTextView.setText(strBuffer.toString());

                int byteLength = tempList.size();  
                if (byteLength &gt;= 2) {  
                    // 判断字节是不是 以 /n/r结尾  
                    if ((tempList.get(byteLength - 1) == 13)  
                            && (tempList.get(byteLength - 2) == 10)) {  
                        strBuffer = new StringBuilder();  
                        tempList.clear();  
                    }  
                }

                break;

**4: 华为C8812E拍照返回来的照片是压缩文件**

   **设置输出的图片文件夹可以解决这个问题：** 

Intent intent = new Intent(MediaStore.ACTION\_IMAGE\_CAPTURE);

 

  intent.putExtra(

                MediaStore.EXTRA\_OUTPUT,

                Uri.fromFile(new File(fileName)));  //图片输出放到的目录

               startActivityForResult(intent, CAMERA\_RESULT\_CODE);); //CAMERA\_RESULT\_CODE自定义的一个值