Where and how to connect to external API in my service class?

In my service class I would like to connect to external API. Where and how should I do it?

1) Inject in constructor ExternalClass and assign to private property. Next in other property in constructor call connect.

public MyClass(ExternalApi externalApi) {     this.externalApi = externalApi;     this.ExternalApiConnect externalApiConnect = externalApi.connect; }      public void firstMethod() {    externalApiConnect.first(); }  public void secondMethod() {    externalApiConnect.second(); } 

2) Outside constructor, so if I build dependencies in DI, then I don’t call connection to external service.

private ExternalApiConnect externalApiConnect;  public MyClass(ExternalApi externalApi) {     this.externalApi = externalApi;  }      public void firstMethod() {    if (externalApiConnect == null) {         externalApiConnect = externalApi.connect;    }    externalApiConnect.first(); }  public void secondMethod() {    if (externalApiConnect == null) {         externalApiConnect = externalApi.connect;    }    externalApiConnect.second(); } 

But now I have two repetitions and I have state in my service class. I don’t think the state should be in service class?

How is the best way for this?

I am not able to connect Android Auto (Sony AX 5000) with my Realme1 (8GB/128 GB)

I am trying to connect Android Auto in Sony AX-5000 with my Realme1 phone, unfortunatley it is showing me “device not supported”. I am able to connect android auto with other phones. Can somebody give me solution to resolve the issue. Is it permission related issue with ColorOS or something else? Many thanks!

System DSN for SQL to connect through ODBC with for a specific port

Earlier we were using default port number on the SQL and import of registry was working fine when configuring the clients to connect through ODBC. Recently we moved to new server where the SQL port is not the default one. We have around 300 client where this change needs to be made. Due to this we are looking for the best way to reconfigure the SYSTEM DSN’s. The registry file content is as below,

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\ODBC Data Sources] “SQLtest”=”SQL Server”

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\SQLtest] “Driver”=”C:\WINDOWS\system32\SQLSRV32.dll” “Description”=”SQLtest” “Server”=”BLR002\MAINT” “Database”=”Maint” “LastUser”=”sa”

Please let me know how to include the specific port number as well into the registry or what is the alternative method that can be used.