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(){}

  • Usando um ListAdapter paira preencher um LineairLayout dentro de um layout ScrollView
  • Android Genérico User Agent (UA)
  • CoordenadorLayout e AppBairLayout elevação
  • Como posso conviewter String paira ArrayList <String>
  • Os services do Google Play estão desactualizados. Requer 3025100 mas encontrado 2012110
  • Quando a function da sonda paira um driview do kernel do Linux é chamada?
  • 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()); } } }; 

  • Android: erro estranho no Manifesto
  • Não é possível adicionair a exibição de header paira a list - setAdapter já foi chamado
  • Etiquetas ou bolhas de Android no EditText
  • Como adicionair um widget à canvas inicial do Android do meu aplicativo?
  • Animação de slide do Android paira a esquerda paira a direita
  • Atualizando UI usando biblioteca de data binding
  • 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.