How much of the cor开发者_Python百科e Java APIs are present in Android API? How proficient will I become in writing core Java applications by writing applications for Android phones?
Android includes the essential packages from the Java SE API (java.lang
, java.util
, java.net
, etc.) but it is nowhere near the full Java SE API. It excludes AWT, Swing, Java 2D, Java Sound, RMI, CORBA, the scripting API, JMX, JAXB, the Java Print Service API, parts of JDBC and probably several other things.
You can easily see for yourself by comparing the package lists for Android and Java SE.
Java vs. Android APIs article from ZDNet explains how much of Java Standard Edition 5.0 core API is present in Android. Is was written in early 2008 and I haven't seen any similar article for newer Android versions, but I believe largely of this article is still true if your application targets Froyo (API 8) or earlier devices.
According to the article, the following packages are supported in Android:
- java.io - File and stream I/O
- java.lang (except java.lang.management) - Language and exception support
- java.math - Big numbers, rounding, precision
- java.net - Network I/O, URLs, sockets
- java.nio - File and channel I/O
- java.security - Authorization, certificates, public keys
- java.sql - Database interfaces
- java.text - Formatting, natural language, collation
- java.util - Lists, maps, sets, arrays, collections
- javax.crypto - Ciphers, public keys
- javax.net - Socket factories, SSL
- javax.security (partial) - Security related
- javax.sound - Music and sound effects
- javax.sql (except javax.sql.rowset) - More database interfaces
- javax.xml.parsers - XML parsing
- org.w3c.dom (but not sub-packages) - DOM nodes and elements
- org.xml.sax - Simple API for XML
The following packages are not supported:
- java.applet
- java.awt
- java.beans
- java.lang.management
- java.rmi
- javax.accessibility
- javax.activity
- javax.imageio
- javax.management
- javax.naming
- javax.print
- javax.rmi
- javax.security.auth.kerberos
- javax.security.auth.spi
- javax.security.sasl
- javax.sql.rowset
- javax.swing
- javax.transaction
- javax.xml (except javax.xml.parsers)
- org.ietf.*
- org.omg.*
- org.w3c.dom.* (sub-packages)
From Froyo (API 8) the support for javax.xml and org.w3c.dom.ls were added, and from Gingerbread (API 9) the new features from Java 6.0 were added (such as String.isEmpty) but many APIs (javax.imageio, javax.print, etc) are still missing.
By the core Java API do you mean J2SE ? In that case, all of Java 6 core API and language constructs are included (except probably the sun package that some use as if it were standard, but its not).
From a technological standpoint, moving from Swing to Android for example is comparable to moving from Swing to SWT (or any other UI framework). The core of the language is there. It's not like moving to j2se that lacks a lot of standard API (although you can find third party substitutes).
Of course there will be differences other than the UI, (like camera API, storing settings, location services etc.) But these differences are expected, and to make another comparison, it's like moving from developing simulation software (where you know about physics and math libraries) to database administration software (where you know about connections and drivers).
You also tagged the question with "java-ee". I don't see why any enterprise API would be included on Android. Those are designed to work within a container (like tomcat is for servlets). On Android all applications run in a standard JVM, although the UI framework behaves somewhat like a container.
The system requirement page in the Android Developer site asks for SDK 5 or 6. I guess you can assume you can use all of Java 6. I used it and haven't found a problem so far.
I didn't quite get the second question. If you mean to ask how proficient you need to be with the Java core classes to write an Android app, I would say the more, the better. It always helps to know the Java core classes. Otherwise you will be trying to learn two things at the same time: the Android environment (its SDK) and the Java core classes. Possible, just takes more time.
精彩评论