2017-09-13 11 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など)を使用してください。

関連する問題