I want to capture image by using camera app and after that i want to display the location where the image was taken ...please help on this..Im trying with Location listner,ExifInterface but i did'nt get
Asked
Active
Viewed 1,506 times
-2
-
http://stackoverflow.com/questions/15403797/how-to-get-the-latititude-and-longitude-of-an-image-in-sdcard-to-my-application – Parag Chauhan Feb 04 '16 at 07:25
2 Answers
1
You can use this method by passing your bitmap & text as parameters:
private Bitmap ProcessingBitmap(Bitmap bm1, String captionString){
Bitmap bm1 = null;
Bitmap newBitmap = null;
try {
Config config = bm1.getConfig();
if(config == null){
config = Bitmap.Config.ARGB_8888;
}
newBitmap = Bitmap.createBitmap(bm1.getWidth(), bm1.getHeight(), config);
Canvas newCanvas = new Canvas(newBitmap);
newCanvas.drawBitmap(bm1, 0, 0, null);
if(captionString != null){
Paint paintText = new Paint(Paint.ANTI_ALIAS_FLAG);
paintText.setColor(Color.BLUE);
paintText.setTextSize(50);
paintText.setStyle(Style.FILL);
paintText.setShadowLayer(10f, 10f, 10f, Color.BLACK);
Rect rectText = new Rect();
paintText.getTextBounds(captionString, 0, captionString.length(), rectText);
newCanvas.drawText(captionString,
0, rectText.height(), paintText);
Toast.makeText(getApplicationContext(),
"drawText: " + captionString,
Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(),
"caption empty!",
Toast.LENGTH_LONG).show();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return newBitmap;
}
Priyank Android
- 34
- 8
-
This worked for me. I just wanna do little enhancement in it. I want to add white text with transparent black background. How to do that?? – Suraj Apr 19 '19 at 12:56
0
First,
add the permission:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Then, use the LocationManager:
LocationManager manager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location loc = manager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double longi = loc.getLongitude();
double lat = loc.getLatitude();
Use this code into your LocationListener
Then, when you save your image, save also the latitude and the longitude in a SQLite database for example:
table: [my_images] : (id, path, latitude, longitude)
Hope it helps.
Nicolas Cortell
- 639
- 4
- 16