We are trying to connect to an application called PTV navigator.
That application works with an remote interface which is a service to interact with PTV navigator.
There are three seps to the navigation service.
1. Create a service connection
2. Bind to the service
3. Receive/send messages from/to the service
At the moment we can't get passed step 2. We've compiled the java-code to an library without any problem. But when we call BindToPTV the B4A-applications stops working. The line "getApplicationContext().bindservice...." generates an error:
java.lang.NullPointerException
at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:109)
at jds.b4a.ptv.PTV.BindToNav(PTV.java:152)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:680)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:308)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at b4a.example.main.afterFirstLayout(main.java:98)
at b4a.example.main.access$100(main.java:16)
at b4a.example.main$WaitForLayout.run(main.java:76)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:212)
at android.app.ActivityThread.main(ActivityThread.java:5135)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
at dalvik.system.NativeStart.main(Native Method)
Any thoughts?
That application works with an remote interface which is a service to interact with PTV navigator.
There are three seps to the navigation service.
1. Create a service connection
2. Bind to the service
3. Receive/send messages from/to the service
B4X:
public void BindToPTV() {
/*The package name of the service is always "com.ptvag.navigation.ri.RIService", the componentName may be different*/
String componentName = "com.ptvag.navigator.app";
/*String componentName = "com.ptvag.navigatortruckplay.app";
String componentName = "com.ptvag.navigatorfleetplay.app";*/
String serviceName = "com.ptvag.navigation.ri.RIService";
Intent i = new Intent();
i.setClassName(componentName, serviceName);
boolean rc = getApplicationContext().bindService(i, serviceConnection, Context.BIND_AUTO_CREATE);
}
At the moment we can't get passed step 2. We've compiled the java-code to an library without any problem. But when we call BindToPTV the B4A-applications stops working. The line "getApplicationContext().bindservice...." generates an error:
java.lang.NullPointerException
at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:109)
at jds.b4a.ptv.PTV.BindToNav(PTV.java:152)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:680)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:308)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at b4a.example.main.afterFirstLayout(main.java:98)
at b4a.example.main.access$100(main.java:16)
at b4a.example.main$WaitForLayout.run(main.java:76)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:212)
at android.app.ActivityThread.main(ActivityThread.java:5135)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
at dalvik.system.NativeStart.main(Native Method)
Any thoughts?