0

Here is what I tried so far. Don't know what I am getting wrong. Works just fine for taking picture and setting it to ImageView, but crashes when I add the code that tries to get location.

protected void onActivityResult(int requestCode, int resultCode, final Intent data) {

    if (resultCode == Activity.RESULT_OK && requestCode == ACTION_IMAGE_CAPTURE) {
        new Thread(new Runnable() {
            public void run() {
                final Bitmap bm = (Bitmap) data.getExtras().get("data");
                Uri uri = data.getData();
                Cursor cursor = getBaseContext().getContentResolver().query(uri, new String[] {android.provider.MediaStore.Images.ImageColumns.LATITUDE,
                        android.provider.MediaStore.Images.ImageColumns.LONGITUDE }, null, null, null);
                if(cursor.moveToFirst()){
                    int latIndex = cursor.getColumnIndex(android.provider.MediaStore.Images.ImageColumns.LATITUDE);
                    int lonIndex = cursor.getColumnIndex(android.provider.MediaStore.Images.ImageColumns.LONGITUDE);
                    double longitu = cursor.getDouble(lonIndex);
                    double latitu = cursor.getDouble(latIndex);
                    Log.d("picloc", longitu + " "+latitu);
                }

                iv.post(new Runnable() {
                    public void run() {
                        iv.setImageBitmap(bm);
                    }
                });
            }

        }).start();
    }
  • Do you have the appropriate permissions? Exactly what error do you get when looking at the logcat? – CodingIntrigue Jul 16 '13 at 11:12
  • yeah i have all the permissions. and it takes the picture fine but when i click ok, it crashes. Haven't tried it on actual device though. Could be the emulator. – user2409569 Jul 19 '13 at 12:37
  • The same question is answered here, But it uses a different method than the one used here [link](http://stackoverflow.com/a/15403927/2409569) – user2409569 Jul 25 '13 at 16:15

0 Answers0