final class MyWebChromeClient extends WebChromeClient
{
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result)
{
Log.d(tag, message);
result.confirm();
return true;
}
}
}
@Override
public void onDestroy()
{
Log.d(tag, "Destroying View!");
super.onDestroy();
}
For debugging purposes, a MyWebChromeClient is created and the onJsAlert() method is overriden.
1.14 Sharing Java classes from another Eclipse Project
Ian Darwin
Problem
You want to use a class from another project, but don't want to copy-and-paste
Solution
Add the project as a "referenced project", and Eclipse (and DEX) will do the work.
Discussion
You often need to re-use classes from another project. In JPSTrack GPS tracking program, the Android version borrows classes like the file I/O module from the Java SE
version. You surely do not want to copy and paste classes willy-nilly from one project
into another, because this makes maintenance improbable.
48 | Chapter 1: Getting Started
www.it-ebooks.info
Figure 1-28.
All you really have to do is declare the project containing the needed classes (the Java
SE version in this case) as a referenced project on the build path. Select Project->Properties->Build Path, select Project, and click "Add". In the screenshot I am adding the
SE project "jpstrack" as a dependency on the Android version project "jpstrack.android".
Since you are probably keeping both projects under source control (if these are programs you ever ship, you should!), remember to tag both projects when you release the
Android project - one of the points in favor of source control is that you need to be able
to re-create exactly what you shipped.
1.15 Referencing libraries to implement external functionality
Rachee Singh
Problem
You need to reference an external library in your source code
1.15 Referencing libraries to implement external functionality | 49