我想通过使用相机应用程序捕获图像,然后我想显示拍摄图像的位置...请帮助这个..我尝试使用位置列表器,ExifInterface但我没有得到
答案 0 :(得分:1)
您可以通过传递位图和放大器来使用此方法。文本作为参数:
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;
}
答案 1 :(得分:0)
首先,
添加权限:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
然后,使用LocationManager
:
LocationManager manager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location loc = manager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double longi = loc.getLongitude();
double lat = loc.getLatitude();
将此代码用于LocationListener
然后,当您保存图像时,还要将纬度和经度保存在SQLite
数据库中,例如:
table:[my_images] :( id,path,latitude,longitude)
希望它有所帮助。