Posts

Showing posts from June, 2018

Storing captured image or an image picked from a gallery in internal storage using file provider android.

Android Camera intent not working in android nougat and above. File provider used to capture an image and pick an image from the gallery.  Capture image from the camera and stored in the internal storage in android nougat and above. It will show you how to use  File Provider  when you set your target SDK as 24 and change following. 1) Create file_path.xml <? xml version= "1.0" encoding= "utf-8" ?> < paths xmlns: android = "http://schemas.android.com/apk/res/android" > < external-path name= "external_files" path= "." /> </ paths > 2) In AndroidMainfest inside application tag //Here authoitties is unique identification of the fileprovider < provider android :name= "android.support.v4.content.FileProvider" android :authorities= "${applicationId}.fileProvider" android :exported= "false" android :grantUriPermissions= "true" > ...

Store GPS Location in image background android.

Store GPS Location in image background android, store latitude and longitude value in the image. Solution: ExifInterface exif; //get the value from google or network operator. double latitude = getLatitude(); double longitude = getLongitude(); try { //pass image file name after capturing an image or an image picked from the gallery.     exif = new ExifInterface("/sdcard/DCIM/"+filename+".jpeg");     int num1Lat = (int)Math.floor(latitude);     int num2Lat = (int)Math.floor((latitude - num1Lat) * 60);     double num3Lat = (latitude - ((double)num1Lat+((double)num2Lat/60))) * 3600000;     int num1Lon = (int)Math.floor(longitude);     int num2Lon = (int)Math.floor((longitude - num1Lon) * 60);     double num3Lon = (longitude - ((double)num1Lon+((double)num2Lon/60))) * 3600000; //saveAttributes to exif     exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, num1Lat+"/1,"+num2Lat+"/...