Example usage for android.provider MediaStore ACTION_IMAGE_CAPTURE

List of usage examples for android.provider MediaStore ACTION_IMAGE_CAPTURE

Introduction

In this page you can find the example usage for android.provider MediaStore ACTION_IMAGE_CAPTURE.

Prototype

String ACTION_IMAGE_CAPTURE

To view the source code for android.provider MediaStore ACTION_IMAGE_CAPTURE.

Click Source Link

Document

Standard Intent action that can be sent to have the camera application capture an image and return it.

Usage

From source file:io.jawg.osmcontributor.ui.activities.PhotoActivity.java

private void takePicture() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        try {//w  w w.  j  a v a2  s  . co  m
            photoFile = createImageFile();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        // Continue only if the File was successfully created
        if (photoFile != null) {
            Uri photoURI = FileProvider.getUriForFile(this, this.getPackageName() + ".fileprovider", photoFile);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
            startActivityForResult(takePictureIntent, REQUEST_CAMERA);
        }
    }
}

From source file:de.wikilab.android.friendica01.HomeActivity.java

void navigate(String arg1) {
    currentMMItem = arg1;//from  w  w w  . j a  v  a2 s  . com

    if (arg1.equals("Timeline")) {
        navigatePostList("timeline");
    }

    if (arg1.equals("Notifications")) {
        navigatePostList("notifications");
    }

    if (arg1.equals("My Wall")) {
        navigatePostList("mywall");
    }

    if (arg1.equals("Update My Status")) {
        navigateStatusUpdate();
    }

    if (arg1.equals("Friends")) {
        navigateFriendList();
    }

    if (arg1.equals("My Photo Albums")) {
        navigatePhotoGallery("myalbums");
    }

    if (arg1.equals("Take Photo And Upload")) {
        Intent in = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        takePhotoTarget = Max.getTempFile();
        in.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(takePhotoTarget));
        startActivityForResult(in, RQ_TAKE_PHOTO);
    }
    if (arg1.equals("Select Photo And Upload")) {
        Intent in = new Intent(Intent.ACTION_PICK);
        in.setType("image/*");
        startActivityForResult(in, RQ_SELECT_PHOTO);
    }
    if (arg1.equals("Messages")) {
        //Intent in = new Intent(HomeActivity.this, MessagesActivity.class);
        //startActivity(in);
        navigateMessages("msg:all");
    }

    if (arg1.equals("Preferences")) {
        navigatePreferences();
    }

    if (arg1.equals("Log Out")) {
        SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(HomeActivity.this)
                .edit();
        //prefs.putString("login_server", null); //keep server and user ...
        prefs.putString("login_user", null);
        prefs.putString("login_password", null); //...only remove password
        prefs.commit();

        finish();
    }

}

From source file:com.ritul.truckshare.RegisterActivity.DriverLicenseActivity.java

public void Image_Picker_Dialog() {

    AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this);
    myAlertDialog.setTitle("Pictures Option");
    myAlertDialog.setMessage("Select Picture Mode");

    myAlertDialog.setPositiveButton("Gallery", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface arg0, int arg1) {
            /* Utility.pictureActionIntent = new Intent(Intent.ACTION_GET_CONTENT, null);
             Utility.pictureActionIntent.setType("image*//*");
                                                          Utility.pictureActionIntent.putExtra("return-data", true);
                                                          startActivityForResult(Utility.pictureActionIntent, Utility.GALLERY_PICTURE);*/
            Intent i7 = new Intent(Intent.ACTION_PICK,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(i7, Utility.GALLERY_PICTURE);
        }//from w w w  .j  a  v  a 2s.  c  o m
    });

    myAlertDialog.setNegativeButton("Camera", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface arg0, int arg1) {
            /*Utility.pictureActionIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(Utility.pictureActionIntent, Utility.CAMERA_PICTURE);*/

            Intent cameraIntent1 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(cameraIntent1, Utility.CAMERA_PICTURE);

        }
    });
    myAlertDialog.show();

}

From source file:ph.devcon.android.profile.EditUserProfileActivity.java

public void onClickUserProfile(View view) {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        EventBus.getDefault().postSticky(new LaunchCameraEvent(profile));
        startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
    }/*ww w . j av a  2  s .c om*/
}

From source file:com.stfalcon.contentmanager.ContentManager.java

public void takePhoto() {
    savedTask = CONTENT_TAKE;/*from   w  ww. j  a  v a 2  s  .c  o m*/
    if (isStoragePermissionGranted(activity, fragment)) {
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            try {
                boolean setPreDefinedCameraUri = isSetPreDefinedCameraUri();

                dateCameraIntentStarted = new Date();
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                if (setPreDefinedCameraUri) {
                    String filename = System.currentTimeMillis() + ".jpg";
                    ContentValues values = new ContentValues();
                    values.put(MediaStore.Images.Media.TITLE, filename);

                    preDefinedCameraUri = activity.getContentResolver()
                            .insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
                    intent.putExtra(MediaStore.EXTRA_OUTPUT, preDefinedCameraUri);
                }
                if (fragment == null) {
                    activity.startActivityForResult(intent, CONTENT_TAKE);
                } else {
                    fragment.startActivityForResult(intent, CONTENT_TAKE);
                }
            } catch (ActivityNotFoundException e) {
                pickContentListener.onError("");
            }
        } else {
            pickContentListener.onError("");
        }
    }
}

From source file:com.scoreflex.ScoreflexView.java

/**
 * The constructor of the view./*from   ww w  .j  a  v a 2s .c o m*/
 * @param activity The activity holding the view.
 * @param attrs
 * @param defStyle
 */
@SuppressWarnings("deprecation")
public ScoreflexView(Activity activity, AttributeSet attrs, int defStyle) {
    super(activity, attrs, defStyle);

    // Keep a reference on the activity
    mParentActivity = activity;

    // Default layout params
    if (null == getLayoutParams()) {
        setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                Scoreflex.getDensityIndependantPixel(R.dimen.scoreflex_panel_height)));
    }

    // Set our background color
    setBackgroundColor(getContext().getResources().getColor(R.color.scoreflex_background_color));

    // Create the top bar
    View topBar = new View(getContext());
    topBar.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            getResources().getDimensionPixelSize(R.dimen.scoreflex_topbar_height), Gravity.TOP));
    topBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.scoreflex_gradient_background));
    addView(topBar);

    // Create the retry button
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    mErrorLayout = (ViewGroup) inflater.inflate(R.layout.scoreflex_error_layout, null);
    if (mErrorLayout != null) {

        // Configure refresh button
        Button refreshButton = (Button) mErrorLayout.findViewById(R.id.scoreflex_retry_button);
        if (null != refreshButton) {
            refreshButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    if (null == Scoreflex.getPlayerId()) {
                        setUserInterfaceState(new LoadingState());
                        loadUrlAfterLoggedIn(mInitialResource, mInitialRequestParams);
                    } else if (null == mWebView.getUrl()) {
                        setResource(mInitialResource);
                    } else {
                        mWebView.reload();
                    }
                }
            });
        }

        // Configure cancel button
        Button cancelButton = (Button) mErrorLayout.findViewById(R.id.scoreflex_cancel_button);
        if (null != cancelButton) {
            cancelButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    close();
                }
            });
        }

        // Get hold of the message view
        mMessageView = (TextView) mErrorLayout.findViewById(R.id.scoreflex_error_message_view);
        addView(mErrorLayout);

    }

    // Create the close button
    mCloseButton = new ImageButton(getContext());
    Drawable closeButtonDrawable = getResources().getDrawable(R.drawable.scoreflex_close_button);
    int closeButtonMargin = (int) ((getResources().getDimensionPixelSize(R.dimen.scoreflex_topbar_height)
            - closeButtonDrawable.getIntrinsicHeight()) / 2.0f);
    FrameLayout.LayoutParams closeButtonLayoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.TOP | Gravity.RIGHT);
    closeButtonLayoutParams.setMargins(0, closeButtonMargin, closeButtonMargin, 0);
    mCloseButton.setLayoutParams(closeButtonLayoutParams);
    mCloseButton.setImageDrawable(closeButtonDrawable);
    mCloseButton.setBackgroundDrawable(null);
    mCloseButton.setPadding(0, 0, 0, 0);
    mCloseButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            close();
        }
    });
    addView(mCloseButton);

    // Create the web view
    mWebView = new WebView(mParentActivity);
    mWebView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    // mWebView.setBackgroundColor(Color.RED);
    mWebView.setWebViewClient(new ScoreflexWebViewClient());
    mWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public boolean onConsoleMessage(ConsoleMessage cm) {
            Log.d("Scoreflex", "javascript Error: "
                    + String.format("%s @ %d: %s", cm.message(), cm.lineNumber(), cm.sourceId()));
            return true;
        }

        public void openFileChooser(ValueCallback<Uri> uploadMsg) {
            // mtbActivity.mUploadMessage = uploadMsg;
            mUploadMessage = uploadMsg;

            String fileName = "picture.jpg";
            ContentValues values = new ContentValues();
            values.put(MediaStore.Images.Media.TITLE, fileName);
            // mOutputFileUri = mParentActivity.getContentResolver().insert(
            // MediaStore.Images.Media.DATA, values);
            final List<Intent> cameraIntents = new ArrayList<Intent>();
            final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            final PackageManager packageManager = mParentActivity.getPackageManager();
            final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
            for (ResolveInfo res : listCam) {
                final String packageName = res.activityInfo.packageName;
                final Intent intent = new Intent(captureIntent);
                intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
                intent.setPackage(packageName);
                cameraIntents.add(intent);
            }

            // Filesystem.
            final Intent galleryIntent = new Intent();
            galleryIntent.setType("image/*");
            galleryIntent.setAction(Intent.ACTION_GET_CONTENT);

            // Chooser of filesystem options.
            final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source please");

            // Add the camera options.
            chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {}));

            mParentActivity.startActivityForResult(chooserIntent, Scoreflex.FILECHOOSER_RESULTCODE);
        }

        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
            openFileChooser(uploadMsg);
        }

        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
            openFileChooser(uploadMsg);
        }
    });
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setDomStorageEnabled(true);
    mWebView.getSettings().setDatabasePath(
            getContext().getFilesDir().getPath() + "/data/" + getContext().getPackageName() + "/databases/");
    addView(mWebView);

    TypedArray a = mParentActivity.obtainStyledAttributes(attrs, R.styleable.ScoreflexView, defStyle, 0);
    String resource = a.getString(R.styleable.ScoreflexView_resource);
    if (null != resource)
        setResource(resource);

    a.recycle();

    // Create the animated spinner

    mProgressBar = (ProgressBar) ((LayoutInflater) getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.scoreflex_progress_bar, null);
    mProgressBar.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
    addView(mProgressBar);
    LocalBroadcastManager.getInstance(activity).registerReceiver(mLoginReceiver,
            new IntentFilter(Scoreflex.INTENT_USER_LOGED_IN));
    setUserInterfaceState(new InitialState());
}

From source file:com.luke.lukef.lukeapp.NewUserActivity.java

/**
 * Creates the intent to start camera/* w  w  w  . java 2  s.  c om*/
 */
private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        // Create the File where the photo should go

        if (photoFile != null) {
            this.photoPath = photoFile.getAbsolutePath();
            // Continue only if the File was successfully created
            Uri photoURI = FileProvider.getUriForFile(this, "com.luke.lukef.lukeapp", photoFile);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
            startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
        } else {
            createImageFile();
            dispatchTakePictureIntent();
        }
    }
}

From source file:br.com.GUI.perfil.PerfilAluno.java

public void usarCamera() {
    /* Calendar cal = Calendar.getInstance();
        String nomeArquivo = cal.get(Calendar.YEAR) +"-" 
        + cal.get(Calendar.MONTH) + "-" 
        + cal.get(Calendar.DAY_OF_MONTH) + "-" 
        + cal.get(Calendar.HOUR_OF_DAY) + "-"
        + cal.get(Calendar.MINUTE);//from  ww w .  j ava 2 s  .  com
                
        Intent i = new Intent("android.media.action.IMAGE_CAPTURE");
                 
         photo = new File(android.os.Environment.getExternalStorageDirectory(), nomeArquivo);
                 
         i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
       selectedImageUri = Uri.fromFile(photo);
       startActivityForResult(i, 100);*/

    //use standard intent to capture an image
    Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    //we will handle the returned data in onActivityResult
    startActivityForResult(captureIntent, 100);

}

From source file:ca.ualberta.cmput301w14t08.geochan.fragments.EditFragment.java

/**
 * Allows the user to change the image attached to their comment or remove it
 * entirely. Prompts the user with an AlertDialog as to which option they would like
 * to select. //from  w  w  w. j  a  va2s .  c  o m
 * @param view The Button pressed to call editImage.
 */
public void editImage(View view) {
    if (view.getId() == R.id.attach_image_button) {
        AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
        dialog.setTitle(R.string.attach_image_title);
        dialog.setMessage(R.string.attach_image_dialog);
        dialog.setPositiveButton("Gallery", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {
                Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(Intent.createChooser(intent, "Test"), ImageHelper.REQUEST_GALLERY);
            }
        });
        dialog.setNegativeButton("Camera", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {
                Intent intent = new Intent();
                intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
                try {
                    imageFile = ImageHelper.createImageFile();
                    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));
                    startActivityForResult(Intent.createChooser(intent, "Test"), ImageHelper.REQUEST_CAMERA);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
        dialog.setNeutralButton("Remove Image", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {
                editComment.setImage(null);
                editComment.setImageThumb(null);
            }
        });
        dialog.show();
    }
}

From source file:org.akvo.rsr.up.UpdateEditorActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mUser = SettingsUtil.getAuthUser(this);
    nextLocalId = SettingsUtil.ReadInt(this, ConstantUtil.LOCAL_ID_KEY, -1);

    // find which update we are editing
    // null means create a new one
    Bundle extras = getIntent().getExtras();
    projectId = extras != null ? extras.getString(ConstantUtil.PROJECT_ID_KEY) : null;
    if (projectId == null) {
        DialogUtil.errorAlert(this, R.string.noproj_dialog_title, R.string.noproj_dialog_msg);
    }//from   ww w  .  j a va  2  s. c o  m
    updateId = extras != null ? extras.getString(ConstantUtil.UPDATE_ID_KEY) : null;
    if (updateId == null) {
        updateId = savedInstanceState != null ? savedInstanceState.getString(ConstantUtil.UPDATE_ID_KEY) : null;
    }

    //Limit what we can write 
    InputFilter postFilter = new InputFilter() {

        @Override
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
                int dend) {
            boolean keepOriginal = true;
            StringBuilder sb = new StringBuilder(end - start);
            for (int i = start; i < end; i++) {
                char c = source.charAt(i);
                if (isCharAllowed(c)) // put your condition here
                    sb.append(c);
                else
                    keepOriginal = false;
            }
            if (keepOriginal)
                return null;
            else {
                if (source instanceof Spanned) {
                    SpannableString sp = new SpannableString(sb);
                    TextUtils.copySpansFrom((Spanned) source, start, sb.length(), null, sp, 0);
                    return sp;
                } else {
                    return sb;
                }
            }
        }

        private boolean isCharAllowed(char c) {
            //                    return !Character.isSurrogate(c); //From API 19
            return !(c >= 0xD800 && c <= 0xDFFF);
        }
    };

    // get the look
    setContentView(R.layout.activity_update_editor);
    // find the fields
    progressGroup = findViewById(R.id.sendprogress_group);
    uploadProgress = (ProgressBar) findViewById(R.id.sendProgressBar);
    projTitleLabel = (TextView) findViewById(R.id.projupd_edit_proj_title);
    projupdTitleCount = (TextView) findViewById(R.id.projupd_edit_titlecount);
    projupdTitleCount.setText(Integer.toString(TITLE_LENGTH));
    projupdTitleText = (EditText) findViewById(R.id.projupd_edit_title);
    projupdTitleText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(TITLE_LENGTH), postFilter });
    projupdTitleText.addTextChangedListener(new TextWatcher() {
        //Show count of remaining characters
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            projupdTitleCount.setText(String.valueOf(TITLE_LENGTH - s.length()));
        }

        public void afterTextChanged(Editable s) {
        }
    });
    projupdDescriptionText = (EditText) findViewById(R.id.projupd_edit_description);
    projupdDescriptionText.setFilters(new InputFilter[] { postFilter });
    projupdImage = (ImageView) findViewById(R.id.image_update_detail);
    photoAndToolsGroup = findViewById(R.id.image_with_tools);
    photoAddGroup = findViewById(R.id.photo_buttons);
    photoCaptionText = (EditText) findViewById(R.id.projupd_edit_photo_caption);
    photoCaptionText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(75), postFilter });
    photoCreditText = (EditText) findViewById(R.id.projupd_edit_photo_credit);
    photoCreditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(25), postFilter });

    positionGroup = findViewById(R.id.position_group);
    latField = (TextView) findViewById(R.id.latitude);
    lonField = (TextView) findViewById(R.id.longitude);
    eleField = (TextView) findViewById(R.id.elevation);
    accuracyField = (TextView) findViewById(R.id.gps_accuracy);
    searchingIndicator = (TextView) findViewById(R.id.gps_searching);
    gpsProgress = (ProgressBar) findViewById(R.id.progress_gps);

    // Activate buttons
    btnSubmit = (Button) findViewById(R.id.btn_send_update);
    btnSubmit.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            sendUpdate();
        }
    });

    btnDraft = (Button) findViewById(R.id.btn_save_draft);
    btnDraft.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            saveAsDraft(true);
        }
    });

    btnTakePhoto = (Button) findViewById(R.id.btn_take_photo);
    btnTakePhoto.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            // generate unique filename
            captureFilename = FileUtil.getExternalPhotoDir(UpdateEditorActivity.this) + File.separator
                    + "capture" + System.nanoTime() + ".jpg";
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(captureFilename)));
            startActivityForResult(takePictureIntent, photoRequest);
        }
    });

    btnAttachPhoto = (Button) findViewById(R.id.btn_attach_photo);
    btnAttachPhoto.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
            photoPickerIntent.setType("image/*");
            startActivityForResult(photoPickerIntent, photoPick);
        }
    });

    btnDelPhoto = (Button) findViewById(R.id.btn_delete_photo);
    btnDelPhoto.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            // Forget image
            update.setThumbnailFilename(null);
            // TODO: delete image file if it was taken through this app?
            // Hide photo w tools
            showPhoto(false);
        }
    });

    btnRotRightPhoto = (Button) findViewById(R.id.btn_rotate_photo_r);
    btnRotRightPhoto.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            // Rotate image right
            rotatePhoto(true);
        }
    });

    btnGpsGeo = (Button) findViewById(R.id.btn_gps_position);
    btnGpsGeo.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            onGetGPSClick(view);
        }
    });

    btnPhotoGeo = (Button) findViewById(R.id.btn_photo_position);
    btnPhotoGeo.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            onGetPhotoLocationClick(view);
        }
    });

    dba = new RsrDbAdapter(this);
    dba.open();

    Project project = dba.findProject(projectId);
    projTitleLabel.setText(project.getTitle());

    if (updateId == null) { // create new
        update = new Update();
        update.setUuid(UUID.randomUUID().toString()); // should do sth
                                                      // better, especially
                                                      // if MAC address is
                                                      // avaliable
                                                      /*
                                                       * WifiManager wifiManager = (WifiManager)
                                                       * getSystemService(Context.WIFI_SERVICE); WifiInfo wInfo =
                                                       * wifiManager.getConnectionInfo(); String macAddress =
                                                       * wInfo.getMacAddress(); if (macAddress == null) txt_View.append(
                                                       * "MAC Address : " + macAddress + "\n" ); else txt_View.append(
                                                       * "MAC Address : " + macAddress + "\n" ); }
                                                       */
        update.setUserId(mUser.getId());
        update.setDate(new Date());
        editable = true;
    } else {
        update = dba.findUpdate(updateId);
        if (update == null) {
            DialogUtil.errorAlert(this, R.string.noupd_dialog_title, R.string.noupd2_dialog_msg);
        } else {
            // populate fields
            editable = update.getDraft(); // This should always be true with
                                          // the current UI flow - we go to
                                          // UpdateDetailActivity if it is sent
            if (update.getTitle().equals(TITLE_PLACEHOLDER)) {
                projupdTitleText.setText(""); //placeholder is just to satisfy db
            } else {
                projupdTitleText.setText(update.getTitle());
            }
            projupdDescriptionText.setText(update.getText());
            photoCaptionText.setText(update.getPhotoCaption());
            photoCreditText.setText(update.getPhotoCredit());
            latField.setText(update.getLatitude());
            lonField.setText(update.getLongitude());
            eleField.setText(update.getElevation());
            if (update.validLatLon()) {
                positionGroup.setVisibility(View.VISIBLE);
            }
            // show preexisting image
            if (update.getThumbnailFilename() != null) {
                // btnTakePhoto.setText(R.string.btncaption_rephoto);
                ThumbnailUtil.setPhotoFile(projupdImage, update.getThumbnailUrl(),
                        update.getThumbnailFilename(), null, null, false);
                photoLocation = FileUtil.exifLocation(update.getThumbnailFilename());
                showPhoto(true);
            }
        }
    }

    // register a listener for a completion and progress intents
    broadRec = new ResponseReceiver();
    IntentFilter f = new IntentFilter(ConstantUtil.UPDATES_SENT_ACTION);
    f.addAction(ConstantUtil.UPDATES_SENDPROGRESS_ACTION);
    LocalBroadcastManager.getInstance(this).registerReceiver(broadRec, f);

    enableChanges(editable);
    btnDraft.setVisibility(editable ? View.VISIBLE : View.GONE);
    btnSubmit.setVisibility(editable ? View.VISIBLE : View.GONE);
    // btnTakePhoto.setVisibility(editable?View.VISIBLE:View.GONE);

    // Show the Up button in the action bar.
    // setupActionBar();
}