单击图像时如何存储位置?

How to store the location when an image is clicked?

我正在开发一个应用程序,其中我必须从 android 相机拍摄一些照片,我需要存储图像和通过网络服务在服务器中单击该图像的位置.所以请帮助我成功完成这项任务。

拍照代码:

public class MyCameraActivity extends Activity {
    private static final int CAMERA_REQUEST = 1888; 
    private ImageView imageView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        this.imageView = (ImageView)this.findViewById(R.id.imageView1);
        Button photoButton = (Button) this.findViewById(R.id.button1);
        photoButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
                startActivityForResult(cameraIntent, CAMERA_REQUEST); 
            }
        });
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
        if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {  
            Bitmap photo = (Bitmap) data.getExtras().get("data"); 
            imageView.setImageBitmap(photo);
        }  
    } 
}

这是一个source

关于获取gps坐标,你应该使用LocationListener:

public class MyCurrentLoctionListener implements LocationListener {

public String myLocation;
private TextView mTextView;

MyCurrentLoctionListener(TextView tv) {
    this.mTextView = tv;    
}

@Override
public void onLocationChanged(Location location) {
    location.getLatitude();
    location.getLongitude();

    mTextView.setText("Latitude = " + location.getLatitude() + " Longitude = " + location.getLongitude());

}

这是一个source

至于在服务器上传输数据,我建议您使用 Retrofit for REST API。如果没有 REST API,请使用提供的 API 服务。