Android Question Accesing Sygic SDK with #Additionaljar

Zockolade

Member
Licensed User
Longtime User
I would like to use some functions of Sygic Remote Api.jar for my project.

Is this possible with JavaObject at all? If yes, how do I start with the integration?

https://developers.sygic.com/documentation.php?action=getstarted_android

So far I have done that:

B4X:
#AdditionalJar: RemoteApi

B4X:
Sub GetContext As JavaObject
    Return GetBA.GetField("context")
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.GetField("processBA")
End Sub
 

Zockolade

Member
Licensed User
Longtime User
OK thanks!!!

Can someone help me with the first steps?

How do I do this in b4a:

add import references of Sygic packages into java code

B4X:
import com.sygic.sdk.remoteapi.Api;
import com.sygic.sdk.remoteapi.ApiCallback;
import com.sygic.sdk.remoteapi.ApiNavigation;
import com.sygic.sdk.remoteapi.events.ApiEvents;
import com.sygic.sdk.remoteapi.exception.NavigationException;

...

Define application framework using Sygic callback mechanism

B4X:
public class MainActivity extends Activity {

    private Api mApi;
    private ApiCallback mApiCallback = new ApiCallback() {

        @Override
        public void onServiceDisconnected() {
        }

        @Override
        public void onServiceConnected() {
        }

        @Override
        public void onEvent(int event, String data) {
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mApi = Api.init(getApplicationContext(), ... , mApiCallback);
    }
}

...

Bind API to Sygic Navigation engine

B4X:
mApi = Api.init(getApplicationContext(), "com.sygic.truck", "com.sygic.truck.SygicService", mApiCallback);

...

Define API opening and closing operations

B4X:
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mApi = Api.init(getApplicationContext(), ... , mApiCallback);
        mApi.connect();
    }

many thanks for your great help
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Can someone help me with the first steps?
To be able to use it in B4A you need to write a wrapper (in JAVA) or using JavaObject. The last one is -in my eyes - more complicated as you need to have more knowledge of java. I cant help on JO.

Search the forum on how to create a library in java for B4A. There are some examples and Tutorials.
You can ask your JAVA Questions in this forum.

You also can create a thread in the Job-Offer forum and hire someone who do the work.
 
Upvote 0
Top