コード例 #1
0
 @Override
 public void onClick(View v) {
   if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
     NotificationUtil.makeToast(getApplicationContext(), R.string.toast_feature_camera);
     return;
   }
   final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
   if (AppUtil.hasImageCaptureBug() == false) {
     intent.putExtra(
         MediaStore.EXTRA_OUTPUT, Uri.fromFile(AppUtil.getTempFile(ChooseServiceActivity.this)));
   } else {
     intent.putExtra(
         android.provider.MediaStore.EXTRA_OUTPUT,
         android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
   }
   startActivityForResult(intent, Constants.CAMERA_PIC_REQUEST);
 }
コード例 #2
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
      if (requestCode == GCAccountStore.AUTHENTICATION_REQUEST_CODE) {
        GCAccounts.all(getApplicationContext(), new AccountsCallback()).executeAsync();
      }
      if (requestCode == PhotosIntentWrapper.ACTIVITY_FOR_RESULT_STREAM_KEY) {
        finish();
      } else if (requestCode == Constants.CAMERA_PIC_REQUEST) {
        // Bitmap image = (Bitmap) data.getExtras().get("data");

        String path = "";
        File tempFile = AppUtil.getTempFile(getApplicationContext());
        if (AppUtil.hasImageCaptureBug() == false && tempFile.length() > 0) {
          try {
            android.provider.MediaStore.Images.Media.insertImage(
                getContentResolver(), tempFile.getAbsolutePath(), null, null);
            tempFile.delete();
            path = MediaDAO.getLastPhotoFromCameraPhotos(getApplicationContext()).toString();
          } catch (FileNotFoundException e) {
            Log.d(TAG, "", e);
          }
        } else {
          Log.e(TAG, "Bug " + data.getData().getPath());
          path =
              Uri.fromFile(new File(AppUtil.getPath(getApplicationContext(), data.getData())))
                  .toString();
        }
        Log.d(TAG, path);
        final GCAccountMediaModel model = new GCAccountMediaModel();
        model.setLargeUrl(path);
        model.setThumbUrl(path);
        model.setUrl(path);

        IntentUtil.deliverDataToInitialActivity(this, model, ppWrapper.getChuteId());
      }
    }
  }