I'm currently trying to create a wrapper for a mapping sdk from Mapfactor and I'm having trouble with the activation of the library.
When I'm running the activation code through my wrapper in B4A I get an error saying that Cleartext HTTP traffic to mapfactor.com not permitted. This message does not appear when I use the library in a project created with Android Studio.
This is the code in the wrapper library that I'm calling from B4A.
I instatiates the wrapper in Activity_Create
and I call the activation logic from a event callback when the library failes to initiate
the mmpfcEngine variable is declared in Process_Globals
I've tried adding
SetApplicationAttribute(android:usesCleartextTraffic, "false")
to the manifest without effect
Any help you could give me would be appreciated.
Edit: Never mind,
SetApplicationAttribute(android:usesCleartextTraffic, "false")
should of courde been set to true. Don't no why I didn't have to add it to the Android Studio project. Sorry.
When I'm running the activation code through my wrapper in B4A I get an error saying that Cleartext HTTP traffic to mapfactor.com not permitted. This message does not appear when I use the library in a project created with Android Studio.
This is the code in the wrapper library that I'm calling from B4A.
ActivateDevice:
public void ActivateDevice(BA ba){
this.ba = ba;
ActivationListener listener = new ActivationListener() {
@Override
public void onActivationFinished(ActivationResult activationResult) {
boolean succeeded = activationResult == MpfcEngine.ActivationResult.SUCCEEDED || activationResult == MpfcEngine.ActivationResult.ALREADY_ACTIVATED;
ba.raiseEventFromUI(this, "onActivationResult".toLowerCase(BA.cul)+"_fire", succeeded);
Log.d("MpfcEngine", "Activationresult is " + succeeded);
}
};
MpfcEngine.getInstance().activateDevice("<Some API-key>", listener);
}
I instatiates the wrapper in Activity_Create
Activity_Create:
Sub Activity_Create(FirstTime As Boolean)
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim engine As JavaObject
engine.InitializeNewInstance("com.company.mapfactorwrapper.MpfcEngineWrapper",Null)
mmpfcEngine = engine
Dim path = rp.GetAllSafeDirsExternal("")(0) As String
mmpfcEngine.InitTomTom(ctxt,path,mmpfcEngine.ENGLISH_US)
Activity.LoadLayout("Layout")
End Sub
and I call the activation logic from a event callback when the library failes to initiate
onEngineInitFinished_Fire:
Sub onEngineInitFinished_Fire(result As Int)
xui.MsgboxAsync(result,"onEngineInitFinished")
If result = mmpfcEngine.SUCCESS Then
Private MapView1 As MapView
Panel1.AddView(MapView1,0,0,Panel1.Width,Panel1.Height)
Else
mmpfcEngine.ActivateDevice()
End If
End Sub
the mmpfcEngine variable is declared in Process_Globals
Process_Globals:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Public mmpfcEngine As MpfcEngineWrapper
Public rp As RuntimePermissions
End Sub
I've tried adding
SetApplicationAttribute(android:usesCleartextTraffic, "false")
to the manifest without effect
Any help you could give me would be appreciated.
Edit: Never mind,
SetApplicationAttribute(android:usesCleartextTraffic, "false")
should of courde been set to true. Don't no why I didn't have to add it to the Android Studio project. Sorry.
Last edited: