Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private NativeMe As JavaObject
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private EditText1 As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Activity.LoadLayout("main")
If FirstTime Then
NativeMe.InitializeContext
End If
Dim s As String = NativeMe.RunMethod("Test", Null)
Log("Test = " & s)
EditText1.Text = s
' Dim s As String = NativeMe.RunMethod("displayDate", Null)
' Log("Test = " & s)
' EditText1.Text = s
End Sub
#IF JAVA
import java.util.*;
import java.text.*;
static public String displayDate() {
Locale currentLocale = Locale.getDefault();
Date today;
String dateOut;
DateFormat dateFormatter;
dateFormatter =
DateFormat.getDateInstance(DateFormat.DEFAULT, currentLocale);
today = new Date();
dateOut = dateFormatter.format(today);
return (dateOut + " " + currentLocale.toString());
}
#End If
#IF JAVA
// Access to the main API for dates, times, instants, and durations.
import java.time.*;
import java.lang.*;
import java.security.*;
// Needed for date format
import java.util.*;
import java.text.*;
//import java.text.spi.*; // doesn't exist
//import java.util.spi; // doesn't exist
import java.time.*;
/* Contains the collections framework, legacy collection classes, event model, date and time facilities,
internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator,
and a bit array). */
import java.util.*;
public static String Test() { //<-- static method
String s, t;
s = "\n\n";
try {
// Maintain backwards compatibility of legacy code
// System.setProperty("java.locale.providers", "COMPAT,CLDR");
Locale currentLocale = Locale.getDefault();
Date today;
String dateOut;
DateFormat dateFormatter;
dateFormatter =
DateFormat.getDateInstance(DateFormat.DEFAULT, currentLocale);
today = new Date();
dateOut = dateFormatter.format(today);
t = Locale.getDefault().getCountry();
s = s + "\n" + "\n" + ("The following " + t);
t = (dateOut + " with the Locales: " + currentLocale.toString());
s = s + (" properties are detected on: " + t);
t = System.getProperty("user.language", "not found!");
s = s + "\n" + "\n" + (" The language is : " + t);
t = System.getProperty("user.script", "not found!");
s = s + "\n" + "\n" + (" The script is : " + t);
t = System.getProperty("user.country", "not found!");
s = s + "\n" + "\n" + (" The country is : " + t);
t = System.getProperty("user.variant", "not found!");
s = s + "\n" + "\n" + (" The variant is : " + t);
t = System.getProperty("os.name", "not specified");
s = s + "\n" + "\n" + (" The name of your operating system is: " + t);
t = System.getProperty("java.version", "not specified");
s = s + "\n" + "\n" + (" The running Java version: " + t);
t = System.getProperty("user.home", "not specified");
s = s + "\n" + "\n" + (" Your user home directory is: " + t);
t = System.getProperty("java.home", "not specified");
s = s + "\n" + "\n" + (" Your JRE installation directory is: " + t);
return s;
} catch (Exception e) {
return(s + "\n" + "\n" + "Caught exception " + e.toString());
}
}
#End If