Use the Android API to read EXIF information for pictures
Layout code:
<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical"Tools:context=". Mainactivity " > <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:onclick= "read"Android:text= "Read exif information" /></LinearLayout>
The code is as follows:
PackageCom.wuyudong.loadimage;Importjava.io.IOException;Importandroid.app.Activity;ImportAndroid.media.ExifInterface;ImportAndroid.os.Bundle;ImportAndroid.view.View; Public classMainactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); } Public voidRead (view view) {Try{exifinterface exif=NewExifinterface ("/sdcard/a.jpg"); String Time=Exif.getattribute (exifinterface.tag_datetime); System.out.println (time); String Model=Exif.getattribute (Exifinterface.tag_model); System.out.println ("Model:" +model); } Catch(IOException e) {//TODO auto-generated Catch blockE.printstacktrace (); } }}
Run the project and print the following results:
09-04 07:51:32.561:i/system.out (11278): 2014:09:06 12:34:25
09-04 07:51:32.561:i/system.out (11278): model:gt-i8558
Android Get Pictures EXIF info