Fetching contributors…
Cannot retrieve contributors at this time
53 lines (43 sloc) 1.8 KB
layout title
JTransc Haxe Android

You can include and call haxe libraries that do stuff on android. You can find all the public android libraries here: (equivalent to ANEs) When targeting Adobe AIR, it should be possible to call ANEs directly.


Also, it is possible to call Android directly including lime library (or using jtransc-media that already includes it). Here there is an example: [])(

You can add and Haxe file with @HaxeAddFilesTemplate. Then in that file you can use #if android preprocessor and use lime.system.JNI class:


class HaxeLimeLanguage {
	static public function getLanguage(): String {
		#if android return getLanguageAndroid();
		#elseif ios return getLanguageIOS();
		#elseif windows return getLanguageWindows();
		#else return 'unknown-unknown';

	#if android
	static private function getLanguageAndroid(): String {
		var getDefaultLocale = lime.system.JNI.createStaticMethod("java/util/Locale", "getDefault", "()Ljava/util/Locale;");
		var locale = getDefaultLocale();
		var getLanguage = lime.system.JNI.createMemberMethod("java/util/Locale", "getLanguage", "()Ljava/lang/String;");
		var language = getLanguage(locale);
		trace('HaxeLimeLanguage: Android: Detected language: $language');
		return language;

	#if ios
	static private function getLanguageIOS(): String {
		return 'unknown-ios';

	#if windows
	static private function getLanguageWindows(): String {
		return 'unknown-windows';