我按日期来吧。
7/18
尝试把eclipse上的项目在android studio上跑起来,有好几个要修改的文件,搞了半天也没调起来。
最后还是重装了一个eclipse,坑爹。
7/19
用eclipse跑项目的时候有几个注意点,
第一个是jar包的添加,右键项目,build path->add Libraries,把项目中用到的jar包都放进一个用户库文件夹下。
在新的IDE开发的时候,我尝试创建一个新的项目,然后发现居然不能运行,出错消息如上。
查阅了很多资料后也没解决问题。最后询问Bob,解决方式是:
Build Path->Configure Build Path->Java Compiler->1.7
第三个问题:android.os.DeadObjectException
修改application中android:hardwareAccelerated:"failed"即可
7/20
这天主要是修改了按钮样式和添加了一个下拉菜单。
参见这个链接吧,我就不再写了。现在发现每天写日报其实可以写详细点的,把用到的技术点都写出来,方便以后参考。
http://blog.csdn.net/lichkingyang/article/details/51985151
7/21,7/22
研究了一下onAcivityResult,有个地方一直不调用onActivityResult函数,后来发现是resultCode的问题。
对于每一个控件设置id,使用View.generateViewId()函数,比如imageTextButtonDiy.setId(View.generateViewId());
7/25
在onActivityResult函数中添加了一个refresh()界面,将“开始拍摄”这一个按钮变为"使用"和"重拍"两个按钮,这个使用的技巧就是重新加载布局。
还有一个按钮按下和抬起的动作设置:
btn_compare.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { img.setImageResource(originPicture.get(projectName)); } else if (event.getAction() == MotionEvent.ACTION_UP) { img.setImageBitmap(bitmap); } return false; } });
7/26
这天做了很多东西,把app的跟拍照相关的主要功能都基本实现了。难点在于tableRow的动态添加和删除,我写了一大段程序,就是根据删除的图框的位置重新布置tableRow。
7/27-7/29这三天都在研究图片清晰度检测功能的实现
Bob这个傻逼让我用安卓调python,呵呵。安卓不能直接调python,他又让我用安卓调C++用C++调python。MDZZ。最后我还是直接用安卓调的C++。这有一个NDK的配置问题。这个我是直接百度的。
注意一下JNI接口的命名规范是:Java_ + 调用该方法的包名(包名的点用_代替) + _ + 调用该接口的类名 + _ + 方法名。
8/2-8/4
这几天是和服务器交互的车辆定损结果展示。这个过程有点复杂,我先把图片发给Bob,Bob把图片筛一下,发给天博,然后天博再用socket和我连接。服务端:就是用一个端口开启服务端,然后server.accept接受连接。
try { server = new ServerSocket(PORT); mExecutorService = Executors.newCachedThreadPool(); //create a thread pool System.out.println("服务器已启动..."); Socket client = null; while(true) { client = server.accept(); //把客户端放入客户端集合中 mList.add(client); mExecutorService.execute(new Service(client)); //start a new thread to handle the connection } }catch (Exception e) { e.printStackTrace(); } 还有一些字符串的处理方面的,我要在图片的结尾加上客户端的ip地址和端口,让天博的服务器作为socket客户端和我连接。
fileName = fileName.substring(0,fileName.lastIndexOf("."))+"_"+ip+":8888"+".jpg";
8/5
与服务器交互的非本车识别。通过线程发送图片,用handler接受返回信息,再显示出来。
这个一次发送两张图片,注意两张图片直接有分界线。
private void checkIsTheSameCar(final File firstFile, final File secondFile) { new Thread(new Runnable() { @Override public void run() { String result = null; String BOUNDARY = UUID.randomUUID().toString(); String PREFIX = "--", LINE_END = "\r\n"; String CONTENT_TYPE = "multipart/form-data"; try { URL url = new URL(requestURL); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout(TIME_OUT); conn.setConnectTimeout(TIME_OUT); conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); conn.setRequestMethod("POST"); conn.setRequestProperty("Charset", CHARSET); conn.setRequestProperty("connection", "keep-alive"); conn.setRequestProperty("Content-Type", CONTENT_TYPE + ";boundary=" + BOUNDARY); if (firstFile != null && secondFile != null) { DataOutputStream dos = new DataOutputStream(conn.getOutputStream()); /* * 第一张图片 */ StringBuffer sb = new StringBuffer(); sb.append(PREFIX); sb.append(BOUNDARY); sb.append(LINE_END); String fileName = firstFile.getName(); // fileName = // fileName.substring(0,fileName.lastIndexOf("."))+"_"+ip+":8888"+".jpg"; sb.append("Content-Disposition: form-data; name=\"file\"; filename=\"" + fileName + "\"" + LINE_END); sb.append("Content-Type: application/octet-stream; charset=" + CHARSET + LINE_END); sb.append(LINE_END); dos.write(sb.toString().getBytes()); InputStream is = new FileInputStream(firstFile); byte[] bytes = new byte[1024]; int len = 0; while ((len = is.read(bytes)) != -1) { dos.write(bytes, 0, len); } is.close(); dos.write(LINE_END.getBytes()); dos.flush(); /** * 第二张图片 */ sb = new StringBuffer(); sb.append(PREFIX); sb.append(BOUNDARY); sb.append(LINE_END); fileName = secondFile.getName(); sb.append("Content-Disposition: form-data; name=\"file\"; filename=\"" + fileName + "\"" + LINE_END); sb.append("Content-Type: application/octet-stream; charset=" + CHARSET + LINE_END); sb.append(LINE_END); dos.write(sb.toString().getBytes()); is = new FileInputStream(secondFile); bytes = new byte[1024]; len = 0; while ((len = is.read(bytes)) != -1) { dos.write(bytes, 0, len); } is.close(); dos.write(LINE_END.getBytes()); dos.flush(); byte[] end_data = (PREFIX + BOUNDARY + PREFIX + LINE_END).getBytes(); dos.write(end_data); dos.flush(); int res = conn.getResponseCode(); if (res == 200) { // Log.e(TAG, "request success"); InputStream input = conn.getInputStream(); StringBuffer sb1 = new StringBuffer(); int ss; while ((ss = input.read()) != -1) { sb1.append((char) ss); } result = sb1.toString(); Message message = new Message(); Bundle bundle = new Bundle(); bundle.putString("message", result); message.setData(bundle); message.what = 1; cMessageHandler.sendMessage(message); } } } catch (Exception e) { // TODO: handle exception } } }).start(); }
8/8
本车识别由于一次要比较两张图片,所以被比对的图片还要进行设置。我用了一个列表保存已经被拍照的照片。
8/9
车牌识别,和本车识别的交互流程基本一样,就是结果的显示位置不同。
8/10
修复bug
8/11
语音app
8/12
焦距检测