2017-10-04 6 views
-5

Je souhaite récupérer uniquement les images capturées sur la caméra avant.Comment obtenir le chemin des images capturées par la caméra avant

Y at-il fonction de l'intention ou les médias qui me donnent tous les chemins d'images dont capturé par la caméra avant (caméra selfie)

de Merci à l'avance.

+0

Je pense que cette aide de lien que vous https://stackoverflow.com/a/4495753/5580210 –

Répondre

1

Y at-il l'intention ou la fonction des médias qui me donnent tous les chemins d'images dont capturé par la caméra avant (caméra selfie)

n °

+0

Ok, Merci pour la information. –

1

Bien qu'il n'y ait pas un moyen simple de le faire , vous pouvez éventuellement obtenir les métadonnées exif pour chaque image dans votre dossier DCIM et ensuite vérifier si le TAG_MODEL (ou toute autre caractéristique) correspond à la spécification de votre caméra frontale.

Exemple de code pour obtenir les métadonnées exif à partir d'un fichier image (source):

public class AndroidExif extends Activity { 

TextView myTextView; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     myTextView = (TextView)findViewById(R.id.textview); 

     //change with the filename & location of your photo file 
     String filename = "/sdcard/DSC_3509.JPG"; 
     try { 
    ExifInterface exif = new ExifInterface(filename); 
    ShowExif(exif); 
    } catch (IOException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
    Toast.makeText(this, "Error!", 
    Toast.LENGTH_LONG).show(); 
    } 
    } 

    private void ShowExif(ExifInterface exif) 
    { 
    String myAttribute="Exif information ---\n"; 
    myAttribute += getTagString(ExifInterface.TAG_DATETIME, exif); 
    myAttribute += getTagString(ExifInterface.TAG_FLASH, exif); 
    myAttribute += getTagString(ExifInterface.TAG_GPS_LATITUDE, exif); 
    myAttribute += getTagString(ExifInterface.TAG_GPS_LATITUDE_REF, exif); 
    myAttribute += getTagString(ExifInterface.TAG_GPS_LONGITUDE, exif); 
    myAttribute += getTagString(ExifInterface.TAG_GPS_LONGITUDE_REF, exif); 
    myAttribute += getTagString(ExifInterface.TAG_IMAGE_LENGTH, exif); 
    myAttribute += getTagString(ExifInterface.TAG_IMAGE_WIDTH, exif); 
    myAttribute += getTagString(ExifInterface.TAG_MAKE, exif); 
    myAttribute += getTagString(ExifInterface.TAG_MODEL, exif); 
    myAttribute += getTagString(ExifInterface.TAG_ORIENTATION, exif); 
    myAttribute += getTagString(ExifInterface.TAG_WHITE_BALANCE, exif); 
    myTextView.setText(myAttribute); 
    } 

    private String getTagString(String tag, ExifInterface exif) 
    { 
    return(tag + " : " + exif.getAttribute(tag) + "\n"); 
    } 
}