Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I save data from Camera to disk using MediaStore on Android?
    primarykey
    data
    text
    <p>For my application, I'd been using my own Camera class for taking images and my own database but soon enough I couldn't really keep up with changes and I decided to use the built in camera application in Android to do the job, but I can't seem to get it to save file. What am I missing here? The application seems to save the file but it's just 0 bytes. I looked up the source code of the Camera application and it's looking for the "output" in Extras to save the file. Any help would be greatly appreciated.</p> <pre><code>Public class CameraTest extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button cameraButton = (Button) findViewById(R.id.cameraButton); cameraButton.setOnClickListener( new OnClickListener(){ public void onClick(View v ){ ContentValues values = new ContentValues(); values.put(Images.Media.TITLE, "title"); values.put(Images.Media.BUCKET_ID, "test"); values.put(Images.Media.DESCRIPTION, "test Image taken"); Uri uri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); intent.putExtra("output", uri.getPath()); startActivityForResult(intent,0); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode== 0 &amp;&amp; resultCode == Activity.RESULT_OK){ ((ImageView)findViewById(R.id.pictureView)).setImageURI(data.getData()); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload