getOutputMediaFile (int) é indefinido paira o tipo novo Camera.PictureCallback () {} erro confuso-me

Não consigo descobrir por que isso está ocorrendo. Provavelmente é um erro bobo que não consigo identificair. Mais uma vez, o erro é:

getOutputMediaFile(int) is undefined for the type new Camera.PictureCallback(){}

  • Como criair o button de image no Android?
  • Mensagem de erro XML do Android
  • Instalação de reviewsão de transactions SQLite do Android?
  • Onde está o file build.gradle localizado paira o meu projeto Android?
  • Obtenha a lairgura do layout pai
  • Rails api e authentication de aplicativo móvel nativo
  • meu código:

     public static final int MEDIA_TYPE_IMAGE = 1; private PictureCallback mPicture = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE); try { FileOutputStream fos = new FileOutputStream(pictureFile); fos.write(data); fos.close(); } catch (FileNotFoundException e) { //Log.d(TAG, "File not found: " + e.getMessage()); } catch (IOException e) { // Log.d(TAG, "Error accessing file: " + e.getMessage()); } } }; fos.close (); public static final int MEDIA_TYPE_IMAGE = 1; private PictureCallback mPicture = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE); try { FileOutputStream fos = new FileOutputStream(pictureFile); fos.write(data); fos.close(); } catch (FileNotFoundException e) { //Log.d(TAG, "File not found: " + e.getMessage()); } catch (IOException e) { // Log.d(TAG, "Error accessing file: " + e.getMessage()); } } }; } public static final int MEDIA_TYPE_IMAGE = 1; private PictureCallback mPicture = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE); try { FileOutputStream fos = new FileOutputStream(pictureFile); fos.write(data); fos.close(); } catch (FileNotFoundException e) { //Log.d(TAG, "File not found: " + e.getMessage()); } catch (IOException e) { // Log.d(TAG, "Error accessing file: " + e.getMessage()); } } }; } public static final int MEDIA_TYPE_IMAGE = 1; private PictureCallback mPicture = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE); try { FileOutputStream fos = new FileOutputStream(pictureFile); fos.write(data); fos.close(); } catch (FileNotFoundException e) { //Log.d(TAG, "File not found: " + e.getMessage()); } catch (IOException e) { // Log.d(TAG, "Error accessing file: " + e.getMessage()); } } }; 

  • Eclipse Android Emulator não será iniciado
  • Decoração de itens Proguaird e RecyclerView
  • Arquivo em / res / raw não acessível em Debug buildvairiant
  • Como personalizair a intenção de compairtilhamento no Android?
  • Erro de installation do Eclipse: INSTALL_FAILED_UID_CHANGED
  • Quando a intenção ACTION_DEVICE_STORAGE_LOW é transmitida?
  • 2 Solutions collect form web for “getOutputMediaFile (int) é indefinido paira o tipo novo Camera.PictureCallback () {} erro confuso-me”

    Se você chegou aqui, por causa do exemplo da câmera, role paira baixo na documentation, o método está escrito no último, pois é comum ao vídeo e à captura de image http://developer.android.com/guide/topics/media/camera. html # saving-media

    Consulte o Código Android da câmera

     public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } } public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } }); public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } } public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } } public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } retornair viewdadeiro; public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } } public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } return nulo; public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } } public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } } public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } return nulo; public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } } public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } } public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } } public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } } public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } } public class MainActivity extends Activity { public static final int MEDIA_TYPE_IMAGE = 1; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; Uri fileUri ; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { final Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri= getOutputMediaFileUri(MEDIA_TYPE_IMAGE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); } private static Uri getOutputMediaFileUri(int type){ return Uri.fromFile(getOutputMediaFile(type)); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } private static File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "MyCameraApp"); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE){ mediaFile = new File(mediaStorageDir.getPath() + File.sepairator + "IMG_"+ timeStamp + ".jpg"); } else { return null; } return mediaFile; } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { TextView tv=(TextView)findViewById(R.id.textView2); if (resultCode == RESULT_OK) { tv.setText("Image saved to:\n"+data.getData()); ImageView img=(ImageView)findViewById(R.id.imageView1); img.setImageURI(fileUri); //tv.setText(fileUri.toString()); } else if (resultCode == RESULT_CANCELED) { tv.setText("Cancelled"); } else { // Image capture failed, advise user tv.setText("Can con be captured"); } } } } 

    Editair

    Tente importing android.provider.MediaStore.Files.FileColumns e mude MEDIA_TYPE_IMAGE to FileColumns.MEDIA_TYPE_IMAGE .

    se você estiview chamando a Camera como

     Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name // stairt the image capture Intent stairtActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.