Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Beginning of an activity to add a photo

  • Loading branch information...
commit ded2b606a994d215ab01a0a0ff4ab97d2ffc2358 1 parent 40fe982
@blanu authored
Showing with 41 additions and 0 deletions.
  1. +41 −0 android/src/net/blanu/sneakermesh/AddPhoto.java
View
41 android/src/net/blanu/sneakermesh/AddPhoto.java
@@ -0,0 +1,41 @@
+package net.blanu.sneakermesh;
+
+public class AddPhoto extends SneakermeshActivity {
+ private Uri imageUri;
+
+ public void takePhoto(View view) {
+ Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
+ File photo = new File(Environment.getExternalStorageDirectory(), "Pic.jpg");
+ intent.putExtra(MediaStore.EXTRA_OUTPUT,
+ Uri.fromFile(photo));
+ imageUri = Uri.fromFile(photo);
+ startActivityForResult(intent, TAKE_PICTURE);
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ switch (requestCode) {
+ case TAKE_PICTURE:
+ if (resultCode == Activity.RESULT_OK) {
+ Uri selectedImage = imageUri;
+ getContentResolver().notifyChange(selectedImage, null);
+ ImageView imageView = (ImageView) findViewById(R.id.ImageView);
+ ContentResolver cr = getContentResolver();
+ Bitmap bitmap;
+ try {
+ bitmap = android.provider.MediaStore.Images.Media
+ .getBitmap(cr, selectedImage);
+
+ imageView.setImageBitmap(bitmap);
+ Toast.makeText(this, selectedImage.toString(),
+ Toast.LENGTH_LONG).show();
+ } catch (Exception e) {
+ Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT)
+ .show();
+ Log.e("Camera", e.toString());
+ }
+ }
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.