2013-07-25 33 views
0

通常情況下,我可以使用以下代碼來獲取照片的路徑,大小和日期等詳細信息。
但是找不到製造商,型號等照片的其他細節,我該怎麼辦?謝謝!如何獲得製造商,照片的模型細節?

String[] projection = new String[]{ 
      MediaStore.Images.Media._ID, 
      MediaStore.Images.Media.BUCKET_DISPLAY_NAME, 
      MediaStore.Images.Media.DATE_TAKEN 
    }; 

    // Get the base URI for the People table in the Contacts content provider. 
    Uri images = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; 

    // Make the query. 
    Cursor cur = managedQuery(images, 
      projection, // Which columns to return 
      "",   // Which rows to return (all rows) 
      null,  // Selection arguments (none) 
      ""   // Ordering 
      ); 

    Log.i("ListingImages"," query count="+cur.getCount()); 

    if (cur.moveToFirst()) { 
     String bucket; 
     String date; 
     int bucketColumn = cur.getColumnIndex(
      MediaStore.Images.Media.BUCKET_DISPLAY_NAME); 

     int dateColumn = cur.getColumnIndex(
      MediaStore.Images.Media.DATE_TAKEN); 

     do { 
      // Get the field values 
      bucket = cur.getString(bucketColumn); 
      date = cur.getString(dateColumn); 

      // Do something with the values. 
      Log.i("ListingImages", " bucket=" + bucket 
        + " date_taken=" + date); 
     } while (cur.moveToNext()); 
    } 

回答

2

使用ExifInterface獲取有關圖片的信息。

它包括:TAG_MAKETAG_MODEL

try { 
     ExifInterface ei = new ExifInterface("file path"); 
     String make = ei.getAttribute(ExifInterface.TAG_MAKE); 
     String model = ei.getAttribute(ExifInterface.TAG_MODEL); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
0

一切都寫在照片的EXIF

您可以使用ExifInterface類來獲取所需的數據。

TAG_MODELTAG_MAKE是什麼讓你感興趣。