Android-dev.it Community

 
Annunci

:arrow: Benvenuto!, se non sei ancora un utente registrato: puoi registrati qui, oppure effettua il login
:arrow: Apri un forum sul tuo nuovo smartphone Android e collabora con noi! (dettagli)

www.agendadigitale.org
Image


Sponsor
It is currently Sat Feb 11, 2012 1:11 pm

All times are UTC + 1 hour


 Topics   Replies   Views   Last post 
No new posts Gridview e focus item

by boriskarloff on Sat Feb 11, 2012 4:29 am in Sviluppo e programmazione in Android

0

6

Sat Feb 11, 2012 4:29 am

boriskarloff

No new posts Attachment(s) aiutino per un applicazione :D

by fillo on Fri Feb 10, 2012 5:58 pm in Sviluppo e programmazione in Android

0

12

Fri Feb 10, 2012 5:58 pm

fillo

No new posts Attachment(s) help raga perchè non mi trova il txt_url?

by fillo on Fri Feb 10, 2012 5:25 pm in Sviluppo e programmazione in Android

3

41

Fri Feb 10, 2012 5:25 pm

fillo

No new posts Riempire spazio orizzontale

by TheSgrash on Thu Feb 09, 2012 9:43 am in Sviluppo e programmazione in Android

2

81

Thu Feb 09, 2012 9:43 am

TheSgrash

No new posts Help creazione immagini

by hero82 on Wed Feb 08, 2012 6:57 pm in Sviluppo e programmazione in Android

2

42

Wed Feb 08, 2012 6:57 pm

hero82




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: leggere le coordinate gps da una foto
PostPosted: Thu Sep 09, 2010 1:59 pm 
Offline
User avatar

Joined: Tue May 18, 2010 2:46 pm
Posts: 5
Punti Android: ?
Ciao a tutti.

Non riesco a leggere le coordinate gps associate ad una foto scattata con HTC Wildfire, Android 2.1.
Guardando tra i dettagli della foto è chiaro che le coordinate gps siano state associate ad essa al momento dello scatto.

Ma andando ad eseguire del codice Java in modo da ottenere tali valori, il risultato è sempre 0.0, 0.0.

Code:
               ContentResolver cr = getContentResolver();
      
      Uri mediaUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
      String[] mediaProjection = { MediaStore.Images.ImageColumns._ID,
                           MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME,
                           MediaStore.Images.ImageColumns.BUCKET_ID,
                           MediaStore.Images.ImageColumns.LATITUDE,
                           MediaStore.Images.ImageColumns.LONGITUDE,
                           MediaStore.Images.ImageColumns.MINI_THUMB_MAGIC };
      
      Cursor mediaCursor = cr.query(mediaUri, mediaProjection, null, null, null);

                if(mediaCursor.moveToFirst()) {
                         do {
            int latitudeColIndex = mediaCursor.getColumnIndex(MediaStore.Images.ImageColumns.LATITUDE);
            int longitudeColIndex = mediaCursor.getColumnIndex(MediaStore.Images.ImageColumns.LONGITUDE);
            
            double latitude = mediaCursor.getDouble(latitudeColIndex);
            double longitude = mediaCursor.getDouble(longitudeColIndex);
            Log.i(this.getClass().getName(), "" + latitude + " " + longitude);

         } while(mediaCursor.moveToNext());
                 }



Grazie


Top
 Profile  
 
 Post subject: Re: leggere le coordinate gps da una foto
PostPosted: Thu Sep 09, 2010 3:45 pm 
Offline
Moderatore
User avatar

Joined: Thu Dec 27, 2007 3:51 pm
Posts: 986
Cellulare Android: HTC Dream
Operatore: TIM
Punti Android: 1320
Ciao,
il tuo snippet di codice mi sembra corretto; alcuni spunti:
- hai provato a verificare dal debugger della Dalvik VM (ddms) se le istruzioni che hai postato generano qualche eccezione ?
- dove stai testando l'applicazione ? sul WildFire oppure sull'emulatore (sull'emulatore potresti avere problemi...)

In alternativa, puoi provare questo metodo alternativo (da android-developers group):
- Lanciare l'intent ACTION_GET_CONTENT
Code:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(  Intent.createChooser(intent,
getText(R.string.get_picture)) , 1);


- Ottenere le info associate all'immagine:
Code:
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
  if (resultCode == RESULT_OK)
  {
    if (requestCode == 1)
    {
      Uri uri = data.getData();
      ContentResolver cr = context.getContentResolver();
      Bitmap bitmap = BitmapFactory.decodeStream( cr.openInputStream(uri) );
      double latitude = 0;
      double longitude = 0;

      Cursor c = cr.query(uri, new String[] {
          MediaStore.Images.ImageColumns.LATITUDE,
          MediaStore.Images.ImageColumns.LONGITUDE
       }, null, null, null);

      if (c != null) {
          c.moveToFirst();
          latitude = c.getDouble(c.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.LATITUDE));
          longitude = c.getDouble(c.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.LONGITUDE));
      }

      // Alternatively if the Camera does not use a media store content uri it could return the latitude and longitude in the extra fields of the intent.
    }
  }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
SitemapIndex SitemapIndex RSS Feed RSS Feed Channel list Channel list
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
phpBB SEO

All trademarks and logos used in this site are of properties of their respective owners.