Marker is not displayed on HERE Map - android-studio

I want a Marker to be displayed on the Map, but it's not displayed, here's the code I used,
I'm using HERE Map SDK for Android
Image img = new Image();
try {
img.setImageResource(R.drawable.marker);
} catch (IOException e) {
e.printStackTrace();
}
MapMarker mm = new MapMarker();
mm.setIcon(img);
mm.setCoordinate(new GeoCoordinate(21.609512, 39.131269));

After creating the MapMarker, you need to add it also to your map via Map.addMapObject(...)
See my example (where mMap is my instance of Map, and the anchor point is on the botton instead of center):
private void addMarker(GeoCoordinate geoCoordinate)
{
if (mMarker == null) {
Image image = new Image();
try {
image.setImageResource(R.drawable.pin);
} catch (final IOException e) {
e.printStackTrace();
}
mMarker = new MapMarker(geoCoordinate, image);
mMarker.setAnchorPoint(new PointF(image.getWidth()/2, image.getHeight()));
mMap.addMapObject(mMarker);
} else {
mMarker.setCoordinate(geoCoordinate);
}
mMap.setCenter(geoCoordinate, Animation.BOW);
}

Related

Set EXIF geolocation using CameraX

How do you add Location information in the image EXIF using CameraX API. I created my own app using https://codelabs.developers.google.com/codelabs/camerax-getting-started/#4.
I sifted through https://developer.android.com/training/camerax and https://developer.android.com/jetpack/androidx/releases/exifinterface but did not found any guides.
If you took a picture you override onImageSaved. There you can write the exif data to your photo. I only have it in Java, but the princip is the same.
ExifInterface exif = null;
try {
exif = new ExifInterface(PhotoPath);
} catch (IOException e) {
e.printStackTrace();
}
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, "location");
The different TAGs you can look up here. How to get the location is here and if you need more information about how to store the location in exif look here.
You can set the location with the Metadata.setLocation method
val metadata = Metadata().apply {
location = Location() // set the location here
}
val contentValues = ContentValues().apply {
put(MediaStore.MediaColumns.DISPLAY_NAME, System.currentTimeMillis())
put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg")
put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DCIM)
}
val contentUri = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY)
val outputOptions = OutputFileOptions.Builder(contentResolver, contentUri, contentValues)
.setMetadata(metadata)
.build()
imageCapture.takePicture(outputOptions, mainExecutor, object : OnImageSavedCallback {
override fun onImageSaved(outputFileResults: OutputFileResults) {
Log.d(TAG, "Photo URI ${outputFileResults.savedUri}")
}
override fun onError(exception: ImageCaptureException) {
Log.e(TAG, "Error", exception)
}
})

JXLS unable to output excel to servlet for user download

Hello im trying to output an excel file generated from a template xls using jxls library but I dont find the way to do so.
My code look like this:
ServletContext contexto = request.getServletContext();
String path = contexto.getRealPath("/lib/xlsx/plantilla.xlsx");
Conexion conexion = new Conexion();
List<Conexion> conexiones = new ArrayList<Conexion>();
ResultSet rs = CargarConsultas.ejecutarConsulta("CONS_GET_TABLA_CONEXION");
try {
while(rs.next()) {
conexion.setIp(rs.getString("ori_ip"));
conexion.setMac(rs.getString("ori_mac"));
conexion.setUrl_destino(rs.getString("url_dest"));
conexion.setSolicitud(rs.getString("time_stamp_solicitud"));
conexion.setUser_id(rs.getString("user_id"));
conexion.setSubida(rs.getString("icoming"));
conexion.setBajada(rs.getString("outgoing"));
conexion.setAutorizacion(rs.getString("time_stamp_autorizacion"));
conexion.setRenovacion(rs.getString("time_stamp_renovacion"));
conexion.setFin_sesion(rs.getString("time_stamp_fin_sesion"));
conexion.setGw_adress(rs.getString("gw_address"));
conexion.setGw_port(rs.getString("gw_port"));
conexiones.add(conexion);
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
File salida = new File(path);
InputStream is = new FileInputStream(salida);
try (FileOutputStream os = new FileOutputStream("salida.xlsx")) {
Context context = new Context();
context.putVar("conexiones", conexiones);
JxlsHelper.getInstance().processTemplate(is, os, context);
} catch (Exception e) {
e.printStackTrace();
}
Please let me knoew if you know how to output it and no save it to server disk.The code works fine. Thanks alot

platformRequest not working in J2ME

I'm triyng to play .mp3 file using platformRequest(). I verified the file path and it is correct. And I'm using Nokia 210 for testing. Please help me to fix this issue.
try {
platformRequest("file:///C:/song.mp3");
} catch (ConnectionNotFoundException ex) {
ex.printStackTrace();
}
I know you have already verified whether there is file or not. though check my below code once and post comment with results.
Added -
public boolean isFileExisted(String path) {
boolean isExisted = false;
FileConnection filecon = null;
try {
filecon = (FileConnection) Connector.open(path, Connector.READ);
isExisted = filecon.exists();
} catch (java.lang.SecurityException e) {
} catch (Exception e) {
} finally {
try {
if (filecon != null) {
filecon.close();
}
catch (Exception e) {
}
}
return isExisted;
}
}
public void playFileFromSDCard() {
String path1 = "file:///C:/song.mp3";
String path2 = "file:///E:/song.mp3";
if (isFileExisted(path1)) {
try {
System.out.println("path1 exist -> calling platform request " + path1);
platformRequest(path1);
} catch (ConnectionNotFoundException ex) {
ex.printStackTrace();
}
}
else if (isFileExisted(path2)) {
try {
System.out.println("path2 exist -> calling platform request " + path2);
platformRequest(path2);
} catch (ConnectionNotFoundException ex) {
ex.printStackTrace();
}
}
else {
System.out.println("both path doesnt exists");
}
}
After so many searches i found some reasons for the issue. This may help for people in future who is having the same problem. refer the following links.
Open file with MIDlet.platformRequest() ,
How to play media file in System media player in j2me????

Getting code from all (closed) files in solution in Visual Studio SDK

I'm trying to get and edit the code of all the html-files in the project
i found a way to loop over all ProjectItems
IEnumerator Projects = _applicationObject.Solution.Projects.GetEnumerator();
while (Projects.MoveNext())
{
IEnumerator Items = ((Project)Projects.Current).ProjectItems.GetEnumerator();
Queue<ProjectItem> ProjectItems = new Queue<ProjectItem>();
while (Items.MoveNext())
{
ProjectItem SubItem = (ProjectItem)Items.Current;
try
{
if (SubItem.Document != null) DocumentIndex.Add(SubItem.Document);
}
catch (Exception Exception)
{
Console.WriteLine(Exception.Message);
//ignore
}
ProjectItems.Enqueue(SubItem);
}
//follow the tree down
while (ProjectItems.Count != 0)
{
ProjectItem ProjectItem = ProjectItems.Dequeue();
if (ProjectItem.ProjectItems != null)
{
foreach (ProjectItem SubItem in ProjectItem.ProjectItems)
{
ProjectItems.Enqueue(SubItem);
try
{
try
{
SubItem.Open(SubItem.Kind);
DocumentIndex.Add(SubItem.Document);
}catch(Exception Ex){
Console.WriteLine(Ex.Message);
}
}
catch (Exception Exception)
{
Console.WriteLine(Exception.Message);
//ignore
}
}
}
}
}
now i can't get to the code of the files that are not open in an editor window.
how do i get and edit the code of "not opened" projectItems?
how do i detect if a file is a code file? (eg: .cs, .html, .htm, .asp, ....
You must open the ProjectItem that you want to read or edit
DTE dte = (DTE)Package.GetGlobalService(typeof(DTE));
var project = dte.Solution.Projects.Item(1);
var projectItems = project.ProjectItems;
var anyItem = projectItems.Item(0);
Window anyItemWindow = anyItem.open()
var selection = anyItem.Document.Selection as TextSelection;
selection.SelectAll();
Console.WriteLine(selection.Text) // All code
anyItem.Document.Close() //Close Document
if you don't open the ProjectItem anyItem.Doument is null.
Note: selection.Insert("") can be used to change the code

Windows Phone C#, UnauthorizedAccessException when creating BitmapImage

I am trying to download image from Internet using async call like this:
private void DoGetAlbumart(object sender, DoWorkEventArgs e)
{
string req = (string)e.Argument;
WebClient wc = new WebClient();
wc.OpenReadCompleted += new OpenReadCompletedEventHandler(ReadWebRequestCallback);
wc.OpenReadAsync(new Uri(req));
}
void ReadWebRequestCallback( object sender, OpenReadCompletedEventArgs e)
{
if (e.Error == null && !e.Cancelled)
{
try
{
BitmapImage image = new BitmapImage();
image.SetSource(e.Result);
SecondTile.Source = image;
}
catch (Exception ex)
{
}
}
else
{
}
}
It seems that when breakpoint hits at BitmapImage image = new BitmapImage(), I got the following exception:
ex = {System.UnauthorizedAccessException: Invalid cross-thread access.
at MS.Internal.XcpImports.CheckThread()
at System.Windows.DependencyObject..ctor(UInt32 nativeTypeIndex, IntPtr constructDO)
at System.Windows.Media.Imaging.BitmapImage..ctor()
What else can I try to get rid of this error?
Callback methods run in background threads, not the UI thread. Unfortunately, BitmapImages can only be instantiated in the UI thread. If you need to access the UI thread from a callback, try the following:
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
BitmapImage image = new BitmapImage();
image.SetSource(e.Result);
SecondTile.Source = image;
});

Resources