Frage

I am creating a application that will call the camera intent, and wanted to add longitude and latitude with the image taken. Would it be posible?

Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
fileUri = Uri.fromFile(getOutputPhotoFile());
i.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

i.putExtra("latitude", "11111");
i.putExtra("longitude", "222");

startActivityForResult(i, CAPTURE_IMAGE_ACTIVITY_REQ );

War es hilfreich?

Lösung

You are using Camera App and this not good for your purpose. because you can not overlay any object on Camera app. you can only get an image from it. So you have to create your built-in camera app and use it for your purpose. I bring an example that use built-in camera.

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<SurfaceView android:id="@+id/CameraView" android:layout_width="fill_parent"􀀁
android:layout_height="fill_parent"></SurfaceView>
</LinearLayout>

now create your activity like this that implements SurfaceHolder.Callback

import android.app.Activity;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public class SnapShot extends Activity implements SurfaceHolder.Callback {
   SurfaceView cameraView;
   SurfaceHolder surfaceHolder;
   Camera camera;
   @Override
   public void onCreate(Bundle savedInstanceState)
   {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      cameraView = (SurfaceView) this.findViewById(R.id.CameraView);
      surfaceHolder = cameraView.getHolder();
      surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
      surfaceHolder.addCallback(this);
   }
   public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
   }
   public void surfaceCreated(SurfaceHolder holder) {
     camera = Camera.open();
     try
     {
        camera.setPreviewDisplay(holder);
     }
        catch (IOException exception)
     {
        camera.release();
     }
     camera.startPreview();
   }
   public void surfaceDestroyed(SurfaceHolder holder) {
   }
}

Andere Tipps

First you have to be sure that the system camera application you are launching accepts the parameters latitude and longitude, otherwise it is meaningless in my opinion.
You need to build your custom camera application which is not hard to realize this.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top