2017-09-13 63 views
0

我需要该程序点击平板电脑上的Android相机按钮,这是我的代码,它工作正常,但我需要它通过程序完成; 非常感谢。以编程方式点击按钮相机Android

private void sacoFotoIngresoLocal() { 

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
    // Ensure that there's a camera activity to handle the intent 
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) { 
     // Create the File where the photo should go 
     File photoFile = null; 
     try { 
      photoFile = createImageFile(); 
     } catch (IOException ex) { 
      // Error occurred while creating the File 

     } 
     // Continue only if the File was successfully created 
     if (photoFile != null) { 
      Uri photoURI = FileProvider.getUriForFile(this,"com.example.android.fileprovider", photoFile); 
      takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); 
      startActivityForResult(takePictureIntent, REQUERIMEINTO_TOMAR_FOTO); 

     } 
    } 
} 

回答

0

在大多数设备(包括大多数平板电脑)上没有“照相机按钮”。此外,出于明显的安全原因,您不能伪造用户输入(硬件或软件)。

如果您想在没有用户介入的情况下拍摄照片,请直接使用相机API,或使用包装它们的第三方库(例如CameraKit-Android,Fotoapparat)。

相关问题