2

I have an android app that fails on android 4.0.X , 4.1.X , 4.2.X to communicate with the API in server side via https protocol.

The official docs say that TLS 1.2 is supported but not enabled by default. I haven't been able to find a way to enable it with Codename one ; how would one enable TLS 1.2 on an android / Codename one app?

Adnane17
  • 119
  • 8

1 Answers1

1

You will need to create a native interface call and then in the native section use one of the methods illustrated here: How to enable TLS 1.2 support in an Android application (running on Android 4.1 JB)

You can create a native interface by following the guideline here or thru the developer guide coverage of this.

Community
  • 1
  • 1
Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • Thanks Shai, actually I tried to create a native interface and put native code but my code is not recognized in the server side. here is my code. `public class NativeCallImpl { public void updateSecurityRules() { try{ ProviderInstaller.installIfNeeded(getApplicationContext()); }catch(Exception exception){ } }` – Adnane17 May 05 '16 at 11:17
  • In case this is not possible , please consider adding this piece of code to avoid TLS version issue in your android generated code. `try{ ProviderInstaller.installIfNeeded(getBaseContext()); }catch(Exception exception){ }` – Adnane17 May 05 '16 at 11:29
  • Did you add the import statement for the `ProviderInstaller` class? Notice you can edit your question and write below it "Update" then post the native code you tried and the error message you got, or you can create a new question related to the error. You can also file an issue asking us to add that code by default as I'm not sure what the implications are of turning this on by default and we'll need to study that https://www.codenameone.com/blog/issue-submission-guideline.html – Shai Almog May 06 '16 at 04:23
  • Thanks Shai, indeed the problem was that I missed to add import statment. My native code become as follows : `public void updateSecurityRules() { try { com.google.android.gms.security.ProviderInstaller.installIfNeeded((android.content.Context) MainClass.getContext()); } catch (com.google.android.gms.common.GooglePlayServicesRepairableException e) { e.printStackTrace(); } catch (com.google.android.gms.common.GooglePlayServicesNotAvailableException e) { e.printStackTrace(); } }`And it works perfectly. – Adnane17 May 06 '16 at 08:01