I have a piece of java code that uses application: this, how do I use it in B4A, thank you very much!
B4A project files: http://zcqsjh.gz01.bdysite.com/GG.zip
B4A project files: http://zcqsjh.gz01.bdysite.com/GG.zip
Java:
public class MyApplication extends Application {
public void onCreate() {
super.onCreate();
RDCpplict.init(this, new Builder()
.setAppId("f153f5646a04598cdf66f1bf9b299a50")
.setChannel("Demo")
.build(), new ISDKinitialize() {
public void initSucceed(RDSDK rdsdk) {
Toast.makeText(getApplicationContext() , "ok", Toast.LENGTH_SHORT).show();
}
public void initError(ErrorCode errorCode) {
Toast.makeText(getApplicationContext() , "err", Toast.LENGTH_SHORT).show();
}
});
}
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
#AdditionalJar:msa_mdid_1.0.13.aar
#AdditionalJar:sdk.aar
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
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.
End Sub
Sub GetBA As JavaObject
Dim jo As JavaObject
Dim cls As String = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetFieldJO("processBA")
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")
Dim jo As JavaObject
jo.InitializeContext
'jo.RunMethod("InitGG",Array(jo)) 'java.lang.RuntimeException: Method: InitGG not matched.
'jo.RunMethod("InitGG",Array(Application)) 'java.lang.reflect.InvocationTargetException
jo.RunMethod("InitGG",Array(GetBA.GetField("context"))) 'java.lang.UnsatisfiedLinkError: No implementation found for void com.bun.lib.a.a(boolean) (tried Java_com_bun_lib_a_a and Java_com_bun_lib_a_a__Z)
End Sub
#if JAVA
import com.prujwk.jdyphn.ww.sdk.Datas.Builder;
import com.prujwk.jdyphn.ww.sdk.Interfaces.ISDKinitialize;
import com.prujwk.jdyphn.ww.sdk.RDCpplict;
import com.prujwk.jdyphn.ww.sdk.RDSDK;
import com.prujwk.jdyphn.ww.sdk.Utils.ErrorCode;
import android.app.Application;
import android.widget.Toast;
public void InitGG(Application appthis) {
RDCpplict.init(appthis, new Builder()
.setAppId("f153f5646a04598cdf66f1bf9b299a50")
.setChannel("Demo")
.build(), new ISDKinitialize() {
public void initSucceed(RDSDK rdsdk) {
Toast.makeText(getApplicationContext(),"ok", Toast.LENGTH_SHORT).show();
}
public void initError(ErrorCode errorCode) {
Toast.makeText(getApplicationContext(),"err", Toast.LENGTH_SHORT).show();
}
});
}
#End If
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub