相机功能不显示图像
Camera Functionality Not displaying Image
我有一个混合应用程序,它打开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 path="file://" + camera.getPath();//警报(路径);. getelementbyid("image1").src =路径;}
public OpenCamera (WebView appView,Activity context) {
这一点。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);
有时在img标签src显示图像,有时不显示。需要帮助才能找出问题所在。
还有,这和方向改变有关吗??
谢谢
我是这样解决的:
添加:
函数openCamera1 () {
result = camera. startcameraactivity ();
path1 = camera.getImagePath1 ();路径= " file://"+ path1;做{
fileIndicator = camera.findEOF ();}, (! fileIndicator)
. getelementbyid("image1").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;
}
问题是在图像写入文件
相关文章:
- 如何使用url加载程序在webpack中导入多个图像
- nodejs-expressjs上传图像并显示它们
- 使用JSP从服务器检索和显示图像
- 角度:在ng重复上切换图像
- 画廊图像未显示
- Phonegap-(安卓/iphone)多个图像的图像库出现问题
- Javascript排序的图像弹出窗口..可以't单独弹出
- 画布数据到图像
- Windows8应用程序(html&Javascript):从图片库(除了文件选择器)显示图像的另一种方式
- 使图像在单击时展开到不大于浏览器
- Html页面上的多个Base64图像和平滑加载
- UIAutomation放大图像
- 使用javascript在Flash中加载外部图像
- 可以在这里为背景图像设置滤镜吗
- 当图像转换为本地存储的DataURL时,EXIF被删除
- 使用 js 将背景图像设置为 HTML
- Javascript将图像src更改为淡入淡出
- 无法在本地计算机中将画布另存为图像
- 压缩phonegap中ios的图像插件
- 如何在鼠标悬停时在另一个图像上滑动图像.