android - How to get MimeType from Camera? -



android - How to get MimeType from Camera? -

i going on surfaceview photographic camera activty in want mimetye file uri of local path while calling gallery can mimetype content uri while loading photographic camera can't mimetype tried convert localpath file content uri tried below:

public static uri getimagecontenturi(context context, file imagefile) { string filepath = imagefile.getabsolutepath(); cursor cursor = context.getcontentresolver().query( mediastore.images.media.external_content_uri, new string[] { mediastore.images.media._id }, mediastore.images.media.data + "=? ", new string[] { filepath }, null); if (cursor != null && cursor.movetofirst()) { int id = cursor.getint(cursor .getcolumnindex(mediastore.mediacolumns._id)); // uri baseuri = uri.parse(stringuri); homecoming uri.withappendedpath(uploadimageuri, "" + id); } else { if (imagefile.exists()) { contentvalues values = new contentvalues(); values.put(mediastore.images.media.data, filepath); homecoming context.getcontentresolver().insert( mediastore.images.media.external_content_uri, values); } else { homecoming null; } } }

follwed link :http://android-er.blogspot.in/2011/04/convert-uri-to-real-path-format.html issue didn't fixed.

how solve there other solution prepare issue.is there please help me friends

if have uri can mimetype like

uri uri = uri.fromfile(file); contentresolver cr = context.getcontentresolver(); string mime = cr.gettype(uri);

or try

// url = file path or whatever suitable url want.

public static string getmimetype(string url) { string type = null; string extension = mimetypemap.getfileextensionfromurl(url); if (extension != null) { mimetypemap mime = mimetypemap.getsingleton(); type = mime.getmimetypefromextension(extension); } homecoming type; }

for more details see these answers

android uri android-sdcard android-contentresolver

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -