I am working on an application, where in i have to take some pictures from the android camera and i need to store both image and the location of that image where it was clicked in server through web services. So please help me in completing this task successfully.
Asked
Active
Viewed 1,325 times
0
-
What's your server API? Have you code to make image and get gps coordinates? – anil Feb 17 '15 at 06:08
-
No, now i have started working on it. through soap the interaction happens. – Android-Learner Feb 17 '15 at 06:33
1 Answers
1
The code for making photo:
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);
}
}
}
This is a source.
As for getting gps coordinates, you should use 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());
}
This is a source.
As for transfer data on server, I can suggest you to use Retrofit for REST API. If there is no REST API, use provided API of your service.