拍摄功能不显示图片

我有一个混合应用程序,打开Android的原生相机。 我的代码:

public class CameraFunActivity extends Activity { OpenCamera openCamera; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); WebView webView=(WebView)findView ById(R.id.webkitWebView1); WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setDatabaseEnabled(true); openCamera=new OpenCamera(webView,CameraFunActivity.this); webView.addJavascriptInterface(openCamera,"camera"); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode== 0 && resultCode == Activity.RESULT_OK){ System.out.println("!!!!!!!!!!!!!!!!!!!!Camera Working..........."); String imagePath = "file:/"+openCamera.getPath(); System.out.println("Image Pathhhhhhhhhh :::::::::::: " + imagePath); openCamera.setPath(imagePath);

..}

HTML:功能captureImage1(){camera.startCamera(); VAR路径=“文件://”+ camera.getPath(); //警报(路径); 。的document.getElementById(“此搜索”),SRC =路径; }

公共OpenCamera(的WebView APPVIEW,活动上下文){
this.mAppView = APPVIEW;
this.context =背景; }

public void setPath(String path){ _path=path; } public String getPath(){ return _path; } public void setBitmap(Bitmap bitmap){ System.out.println("setting bitmap"); this.bitmap=bitmap; } public Bitmap getBitmap(){ System.out.println("getting bitmap"); return bitmap; } public void startCamera(){ /* Camera camera = Camera.open(); Camera.Parameters parameters = camera.getParameters(); parameters.setPictureFormat(PixelFormat.JPEG); camera.setParameters(parameters);*/ Date dt = new Date(); int date=dt.getDate(); int hours = dt.getHours(); int minutes = dt.getMinutes(); int seconds = dt.getSeconds(); String curTime = date+"_"+hours + "_"+minutes + "_"+ seconds; _path=Environment.getExternalStorageDirectory() +"/"+curTime+".jpg"; File file = new File( _path ); Uri outputFileUri = Uri.fromFile( file ); Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE ); intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri ); // System.out.println("Paramssssssssssssss " + camera.getParameters().toString()); context.startActivityForResult(intent,0);

有时它dispalays在img标签src中的形象,有时没有。 需要帮助找出问题。

此外,有一些相关的方向改变?

谢谢

--------------解决方案-------------

我决定它是这样的:

补充:
功能openCamera1(){
结果= camera.startCameraActivity1();
PATH1 = camera.getImagePath1();
PATH =“文件://”+路径1; 做{
fileIndicator = camera.findEOF();
}而(!fileIndicator)
。的document.getElementById(“此搜索”),SRC =路径;
}

而在OpenCamera添加一个方法:

public boolean findEOF(){
File file=new File(imagePath1);
System.out.println("Inisde EOFL::::::::::::::"+file.length());

if(file.length()>0){
System.out.println("Inisde length is::::::::::::::"+file.length());
return true;
}
return false;

}

所以,问题是得到的ImagePath()中的图像被写入文件之前被调用

分类:JavaScript的 时间:2013-08-12 人气:0
分享到:

相关文章

Copyright (C) 55228885.com, All Rights Reserved.

55228885 版权所有 京ICP备15002868号

processed in 0.347 (s). 9 q(s)