Display static google map location in android application - java

Here is my code for displaying static google map in android application using html,But when i open the activity it shows blank.
please help me to solve the issue,im new in android,
JAVA
WebView overview = (WebView) findViewById(R.id.googlemap_webView);
overview.loadUrl("file:///android_asset/content/googlelocation.html");
googlelocation.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<iframe width="600" height="450" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?q=Crescent%20Builders%2C%20Cherooty%20Road%2C%20Vellayil%2C%20Calicut%2C%20Kerala%2C%20India&key=AIzaSyCeBlSt-PVun7-08LrM6mIS5Nd0NCRVpDM"></iframe>
</body>
</html>

Static maps have been added in the last version of Google Maps for Android. See https://developers.google.com/maps/documentation/android/lite
Unless you have a good reason to use the web version, Android specific one will work better.

Related

xmlns:th="http://www.thymeleaf.org" cannot be fetch by intellij

I am learning spring boot and there is a problem in my thymeleaf template.
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div th:if="${message}">
</div>
</body>
</html>
When i fetch the external resource, there is an invalid URL exception saying: No XML at the specified location: http://www.thymeleaf.org
The dependency in maven is imported. I am using Intellij Community 2021.3.2
I was having the same issue in IntelliJ and I fixed it with this solution:
Navigate to the following File > Settings > Plugins
From here you will search "ThymeLeaf" once you do "JBLHtmlToThymeLeaf" will come up
Install it
Then go to your HTML file, right click it and select "JBLHtmlToThymeleaf"
This will add namespace(xmlns:th="http://www.thymeleaf.org") attribute to HTML tag.

Render fragment contents with Thymeleaf

I'm tryting to have email templates rendered using Thymeleaf and I would like to have the subject and the body in the same file, but rendered separately. I do not want to use spring view, just plain SpringTemplateEngine.
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<!--/*#thymesVar id="user" type="com.myapp.user.User"*/-->
<!--/*#thymesVar id="invitationId" type="java.util.UUID"*/-->
<head>
<title th:fragment="subject">Hello <span th:text="${user.name}"/></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<p>
Hello <span th:text="${user.name}"></span>,<br>
you've been invited to join MyApp.
</p>
<p>
Click on the following link to confirm your email and setup a password:<br>
<a th:href="#{https://myapp.com/accept-invitation(id=${invitationId})}">Accept invitation</a>
</p>
<p>
Best regards,<br/>
<em>The MyApp team</em>
</p>
</body>
</html>
There are several problems with this
First, I'm unable to get Thymeleaf render only contents of <title>
String subject = templateEngine.process(
templateFile,
ImmutableSet.of("subject"),
new Context(Locale.ENGLISH, contextVariables)
);
it renders literary only Hello - it looks like the opening <title> tag is always removed and the fragment is trimmer right after the first tag.
And when I render the whole template, it returns
<!DOCTYPE html>
<html>
<head>
Hello <span>pepa</span></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<p>
Hello <span>pepa</span>,<br>
...
Using the following in the <title> makes the output a bit nicer
<span th:text="${user.name}" th:remove="tag"></span>
but the opening tag is still missing.
When I would theoretically succeed in rendering the title correctly, I'd still have it wrapped in an HTML tag - which obviously cannot be used as an email subject. Is there a way to render only contents of the fragment?
I would really like to have both the email subject and body in the same template for cases, when for example I want to do some iteration in the title to generate it from a list - I do not want to do any string concatenations, I wanna have it in the template.
Any suggestions please?
If you want to include only the content of your fragment, assuming that your fragment is called your_fragment.html and is placed under /resources/templates/fragments you can do:
<head>
<title th:replace="fragments/your_fragment::your_fragment"/></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
And your_fragment.html:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head></head>
<body>
<div th:fragment="your_fragment" th:remove="tag">
Hello <span th:text="${user.name}" th:remove="tag"></span>
</div>
</body>
</html>
This will render:
<head>
Hello username
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>

Offline cache using manifest appcache

I am trying to make my application offline enabled.
This is my starting page of the app which I have put on TOMCAT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html manifest="test.appcache">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
Hello World
</body>
</html>
And Here is my test.appcache (although I am not using any of the files mentioned in my manifest files at this point - its just a POC)
CACHE MANIFEST
#version 821
CACHE:
test.html
/resources/test.js
NETWORK:
*
FALLBACK:
test.html
test.html runs fine in online mode in localhost:8080/myapp/test.html
But when I stop the TOMCAT and try to run it
this is what I get -
Why is my HTML page test.html not getting served from cache when I stop TOMCAT server!
Thanks
Try changing the doctype of your HTML doc to
<DOCTYPE html>
the manifest attribute is HTML5.
https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache

Applet Class Not Found Error

i have just started learning jsp, i came across running Applet from jsp, the code below doesn't seems to work.
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>InfoVisual</title>
</head>
<body>
<jsp:plugin type="applet" codebase="WEB-INF/classes" code="DemoApplet.class" width="400" height="400">
<jsp:fallback>
<p>Unable to load applet</p>
</jsp:fallback>
</jsp:plugin>
<input name="btnShow" value="Show" type="submit">
</body>
</html>
My eclipse project structure is like below
I don't know why i can't see the applet running.
Have i placed files in right folders???
Classes in WEB-INF/classes are only visible to server-side code such as servlets. Instead create a JAR file containing the compiled classes required to run the applet are place them in the same location as the JSP file. The plugin tag will then look like
<jsp:plugin type="applet" code="DemoApplet.class" archive="MyAppletJar.jar" width="400" height="400">
<jsp:fallback>
<p>Unable to load applet</p>
</jsp:fallback>
</jsp:plugin>
this code worked perfectly:
<applet code="DemoApplet.class" name="DemoApplet" archive="DemoApplet.jar" width=300 height=300>
</applet>
and here is my project structure:
Thanx for the help :))

Package Beans does not Exist

I am a .NET developer dabbling into the JSP world. I loaded NetBeans 6.5.1 and get an error in this page:
<%#page import="java.io" %>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"w3.org/TR/html4/loose.dtd">;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
the error is:
"Package Beans does not Exist"
I should add that I created a new Java Web Application and then copy-and-pasted some code that called for the above import. then I get the error.
Help with this error would be great along with any tutorials or books.
Something is wrong with the classpath. Your configuration of the server, plus setup in the WAR file, should be checked against a working one.

Categories