資源描述:
《android拍照和上傳》由會(huì)員上傳分享,免費(fèi)在線(xiàn)閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、19/19Android拍照,上傳,預(yù)覽綜合最近需要做手機(jī)拍照([1]、調(diào)用系統(tǒng)相機(jī)【博客最后】;[2]、自己寫(xiě)照相機(jī)布局),預(yù)覽,上傳功能。特地研究了下android的手機(jī)拍照,其實(shí)不難。參考:http://blog.csdn.net/cfwdl/article/details/5746708http://mjbb.iteye.com/blog/1018006http://blog.csdn.net/hellogv/article/details/59624941、上傳文件功能沒(méi)啥好說(shuō)的,網(wǎng)上很多講的,只要細(xì)心點(diǎn)
2、,按照格式來(lái)寫(xiě)發(fā)送的數(shù)據(jù),都是沒(méi)有問(wèn)題的。如果遇到問(wèn)題,歡迎留言討論、2、預(yù)覽也沒(méi)啥講的,就用Gallery和ImageSwitcher就行,我做的很簡(jiǎn)單(參考代碼)。附上流程圖:?拍照功能:【預(yù)覽尺寸有知道的朋友留言告知?!?9/19Java代碼?import?java.io.BufferedOutputStream;??import?java.io.File;??import?java.io.FileOutputStream;??import?java.io.IOException;????import?and
3、roid.app.Activity;??import?android.app.AlertDialog;??import?android.content.DialogInterface;??import?android.content.Intent;??import?android.graphics.Bitmap;??import?android.graphics.BitmapFactory;??import?android.graphics.PixelFormat;??import?android.hardware
4、.Camera;??import?android.hardware.Camera.AutoFocusCallback;??import?android.hardware.Camera.PictureCallback;??import?android.hardware.Camera.ShutterCallback;??import?android.os.Bundle;??import?android.os.Environment;??import?android.util.Log;??import?android.v
5、iew.KeyEvent;??import?android.view.SurfaceHolder;??import?android.view.SurfaceView;??import?android.view.View;??import?android.view.View.OnClickListener;??import?android.widget.Button;????import?com.peacemap.photo.po.Const;??/**??*?拍照??*?@author?Administrator?
6、?*/??public?class?TakePhotoAct?extends?Activity?implements?SurfaceHolder.Callback{????????????private?static?String?imgPath?=?Environment.getExternalStorageDirectory().getPath()?+?"/"+Const.imageDir;????????????private?SurfaceView?surfaceView;???//相機(jī)畫(huà)布??????pr
7、ivate?SurfaceHolder?surfaceHolder;???????private?Button?takePicView,exitView;????????????private?Camera?mCamera;????//照相機(jī)????????????@Override??19/19????public?void?onCreate(Bundle?savedInstanceState)?{????????????????????super.onCreate(savedInstanceState);???
8、???????setContentView(R.layout.main);??//這里我在AndroidManifest.xml的activity中添加了android:theme="@android:style/Theme.NoTitleBar.Fullscreen"????????????/**??????????*?隱藏狀態(tài)欄和標(biāo)題欄?????????