void handleSendImage(Intent intent) { imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); if (imageUri != null) { // Update UI to reflect image being shared // check for EXIF data try { String picPath = PictureUtility.getRealPathFromURI(imageUri, SavePlace.this); System.out.printf("Path is:", picPath); int[] tempCoords = PictureUtility.getCoordsFromPhoto(picPath); if (!PictureUtility.isCoordinatesValid(tempCoords)) { // EXIF Coords were NOT found Log.i("PictureUtlity", "EXIF Coords were NOT found"); } else { // EXIF Coords were found Log.i("PictureUtlity", "EXIF Coords were found!"); } } catch (Exception e) { Log.i("IMAGE Getter", "Could not get image"); } } }
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_addplace); connectViewElements(); // Get intent, action and MIME type Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) { origin = 0; // NFC getNfcTagInfo(intent); } else { if (Intent.ACTION_SEND.equals(action) && type != null) { origin = 1; // Photo getPhotoInfo(type, intent); } // String photoPath = getIntent().getStringExtra("placePhotoPath"); if (placePic != null) { Bitmap ThumbImage = PictureUtility.decodeSampledBitmapFromPath( PictureUtility.getRealPathFromURI(imageUri, SavePlace.this), 400, 400); placePic.setImageBitmap(ThumbImage); } } savePlace.setOnClickListener( new OnClickListener() { public void onClick(View v) { switch (origin) { case 0: // nfc newPlace.setAudioLocation(audioLoc); newPlace.setNote(commentBlock.getText().toString()); newPlace.setVideoLocation(videoLoc); PropertiesUtility.writePlaceToFile(v.getContext(), newPlace); Intent intent = new Intent(v.getContext(), ActivityMap.class); intent.putExtra("origin", origin); Places.getItems().add(newPlace); startActivity(intent); finish(); break; case 1: // photo String picPath = PictureUtility.getRealPathFromURI(imageUri, SavePlace.this); int[] tempCoords = PictureUtility.isCoordinatesValid(PictureUtility.getCoordsFromPhoto(picPath)) ? PictureUtility.getCoordsFromPhoto(picPath) : currentCoordinates; if (PictureUtility.isCoordinatesValid(tempCoords)) { newPlace = new Place(new GeoPoint(tempCoords[0], tempCoords[1]), "", ""); newPlace.setAudioLocation(audioLoc); newPlace.setNote(commentBlock.getText().toString()); newPlace.setVideoLocation(videoLoc); newPlace.setPhotoLocation( PictureUtility.getRealPathFromURI(imageUri, SavePlace.this)); PropertiesUtility.writePlaceToFile(v.getContext(), newPlace); Intent intent3 = new Intent(v.getContext(), ActivityMap.class); Places.getItems().add(newPlace); intent3.putExtra("origin", origin); startActivity(new Intent(v.getContext(), HomePage.class)); startActivity(intent3); finish(); } else { Intent intent2 = new Intent(v.getContext(), ChooseMethodForLocation.class); intent2.putExtra("origin", origin); startActivityForResult(intent2, 1); } break; default: System.err.println("Unknown source type"); break; } } }); recordAudio.setOnClickListener( new OnClickListener() { public void onClick(View v) { Button recBt = (Button) v; if (recBt.getText().equals(v.getResources().getString(R.string.rec_start_button))) { recBt.setText(v.getResources().getString(R.string.rec_stop_button)); mRecorder = AudioUtility.getMediaRecorder(); audioLoc = AudioUtility.startRecording(mRecorder); } else { recBt.setText(v.getResources().getString(R.string.rec_start_button)); AudioUtility.stopRecording(mRecorder); } } }); playAudio.setOnClickListener( new OnClickListener() { public void onClick(View v) { if (playAudio.getText().equals(v.getResources().getString(R.string.rec_play_button))) { if (audioLoc.length() > 5) { playAudio.setText(v.getResources().getString(R.string.rec_stop_button)); mPlayer = AudioUtility.startPlaying(audioLoc); } } else { playAudio.setText(v.getResources().getString(R.string.rec_play_button)); AudioUtility.stopPlaying(mPlayer); } } }); recordVideo.setOnClickListener( new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); Uri fileUri = VideoUtility.getOutputMediaFileUri(VideoUtility.MEDIA_TYPE_VIDEO); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); startActivityForResult(intent, VideoUtility.CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE); } }); playVideo.setOnClickListener( new OnClickListener() { public void onClick(View v) { if (videoLoc.length() > 5) { Intent intent = new Intent(v.getContext(), PlayVideo.class); intent.putExtra("videoLoc", videoLoc); startActivityForResult(intent, 0); } } }); }