-2

I am a developer new to Android en Eclipse (not to Java), using the latest ADT and Java SE 7u25. I am using a BitSet while working in the Android environment. In Java 7 there is the toByteArray method (toByteArray - Java 7 doc). However the method is not found (build error). Referring to the Android reference (BitSet - Android doc), we can note that the method is not included. This seems the same for other methods of BitSet new in Java 7.

The question: is it possible to use this new method in the Android environment?

Thank you in advance

1 Answers1

1

Android runs a class library that is (largely) compatible with Java 6. Classes and methods introduced in Java 7 are not available at the present time.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    This is no longer true. Android KitKat (which is still a ridiculous name) has added support for some features of the Java 7 API, including the method the question asked about (see http://developer.android.com/reference/java/util/BitSet.html#toByteArray() ). – Jules Dec 11 '13 at 15:45
  • @Jules: True, though it will be a couple of years before developers are regularly creating apps with `minSdkVersion` of 19 or higher. – CommonsWare Dec 11 '13 at 15:46
  • Depends on the kind of development you're doing. My main line of work is writing corporate information handling apps, so I get to specify exactly what hardware will be used. As I find myself greatly resenting not being able to use try-with-resources when developing Android code, I'll certainly be suggesting the acquisition of devices with KitKat for my next project. – Jules Dec 11 '13 at 15:51
  • 1
    @Jules: There are developers in position to limit their development to API Level 19 and higher. Today (11 December 2013), few can, because either they are targeting public distribution (e.g., Play Store), or they are building an enterprise app for a BYOD firm, or they are building an enterprise app for a firm that standardized on pre-Android 4.4 devices, etc. – CommonsWare Dec 11 '13 at 15:52