#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
Private NativeMe As JavaObject
Private Button1 As B4XView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
If FirstTime Then
NativeMe.InitializeContext
End If
File.Copy(File.DirAssets, "img1.jpg", File.DirInternal,"img1.jpg")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Private Sub Button1_Click
Dim s As String = NativeMe.RunMethod("FirstMethod", Null)
Log(s)
Dim base0 As String = Base64EncodeDecodeImage.Base64ImageToString(File.DirInternal,"img1.jpg")
Dim s As String = NativeMe.RunMethod("checkBase64", Array As String(base0))
Log(s)
End Sub
#If JAVA
import java.util.Base64;
public static boolean checkBase64(String s64) {
Base64.Decoder decoder = Base64.getDecoder();
try {
decoder.decode(s64);
} catch(IllegalArgumentException iae) {
// That string wasn't valid.
return false;
}
return true;
}
public static String FirstMethod() { //<-- static method
return "Hello world!";
}
#End If