Java Question bindService in a Wrapper

TheMightySwe

Active Member
Licensed User
Longtime User
These are two different things. SLC build process is not related to Eclipse.


Hi again,

now the .so files are in the .jar

And the SLC works.

armeabi4.png


But still I get this error.

B4X:
java.lang.UnsatisfiedLinkError: Couldn't load pclapi: findLibrary returned null
    at java.lang.Runtime.loadLibrary(Runtime.java:365)
    at java.lang.System.loadLibrary(System.java:535)
    at se.iqpd.checkout.plus.ISMP_Companion.Initialize(ISMP_Companion.java:133)
    at se.iqpd.checkout.plus.main._activity_resume(main.java:1465)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:158)
    at se.iqpd.checkout.plus.main.afterFirstLayout(main.java:104)
    at se.iqpd.checkout.plus.main.access$100(main.java:16)
    at se.iqpd.checkout.plus.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:605)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4514)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
    at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **
 

TheMightySwe

Active Member
Licensed User
Longtime User
Hi Erel

I give up now, I just do a whole Activity in Java and call it with from my app with an intent and return an true or false from that, this is to hard for me.

Thanks for all the help.
 

TheMightySwe

Active Member
Licensed User
Longtime User
You will need to copy it to File.DirInternal and then load it. You can get this folder in your Java code by calling anywheresoftware.b4a.objects.streams.File.getDirInternal.

That I can do in Activity_Create in tha absolute first line, just do a "File.Exist" first I Guess. I'll try that. Thanks!

/J
 

TheMightySwe

Active Member
Licensed User
Longtime User
You will need to copy it to File.DirInternal and then load it. You can get this folder in your Java code by calling anywheresoftware.b4a.objects.streams.File.getDirInternal.

Back to square one!

Oh my god, now when i got the .so files to work, i get a error when installing on a Samsung Tab 3, Application not compatible!

Maybe I need to connect with the service and AIDL-files instead. 40% of our users has Tab 3.

This is the instructions.

B4X:
Use PclService.apk
1. Create a package com.ingenico.pclservice in the src/ directory of your project
2. Copy the aidl files from %Add-on_Dir%\Android\SDK\ to the previously created package to be able to use the PclService features:
IPclService.aidl
IPclServiceCallback.aidl
TransactionIn.aidl
TransactionOut.aidl
3. Copy file %Add-on_Dir%\Android\SDK\Transaction.jar in the libs/ directory of the project and add it to the Java Build Path as an external library

This is thejava code snippet to connect.

B4X:
public class YourActivity extends Activity {
// Declare IPclService interface
protected IPclService mPclService = null;
// Declare Serviceconnection
private PclServiceConnection mServiceConnection;
// Implement ServiceConnection
class PclServiceConnection implements ServiceConnection
{
public void onServiceConnected(ComponentName className, IBinder boundService )
{
mPclService = IPclService.Stub.asInterface((IBinder)boundService);
}

public void onServiceDisconnected(ComponentName className)
{
mPclService = null;
}
};
// You can call this method in onCreate for instance to bind to
// the service
private void initService()
{ mServiceConnection = new PclServiceConnection();
Intent i = new Intent();
i.setClassName( "com.ingenico.pclservice",
"com.ingenico.pclservice.PclService" );
getApplicationContext().bindService( i, this.mServiceConnection,
Context.BIND_AUTO_CREATE);
}
// You can call this method in onDestroy for instance to unbind
// from the service
private void releaseService()
{
getApplicationContext().unbindService( this.mServiceConnection);
}
};

Before i start, do you see ANYTHING in this that might be a problem with B4A, Do i need to exchange anything with the BA object?
 

TheMightySwe

Active Member
Licensed User
Longtime User
You will need a have a good understanding of Android Java API in order to build this library.


I don't have that, but i will have help from the author next week i hope. Are you going to be availible next week if we have any questions about B4A?

A other option is maybe to build a app in java and call it from B4A and get a return value from that intent? Do you think that is a better option?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I will be here next week. However I'm unable to provide private technical support.

A other option is maybe to build a app in java and call it from B4A and get a return value from that intent? Do you think that is a better option?
It is hard to say. If you can build a Java app then you can also build a library and use it from B4A. However if it is easier for you then it can work.
 

TheMightySwe

Active Member
Licensed User
Longtime User
I will be here next week. However I'm unable to provide private technical support.


It is hard to say. If you can build a Java app then you can also build a library and use it from B4A. However if it is easier for you then it can work.


There is no possibility that the new update with #AdditionalJar will work with this complex library?
 

TheMightySwe

Active Member
Licensed User
Longtime User
Hi again, was searching around for answers to my problem in the forum. I found a thread about this.

There is actually a way to change the B4A activity parent class. It is not exposed as I wasn't sure that there is a valid use case for it.


B4X:
#Extends: SDKActivities.Activity

B4X:
public class main extends TooleapActivities.Activity implements B4AActivity {

Is this something I can use in my code as shown above?
 

TheMightySwe

Active Member
Licensed User
Longtime User
I have still not been able to fix my problem. I think it has something to do with the BindService binds to the wrong Activity or something like that.


If you look at the B4A's java-code in Eclipse it has a Object called "processBA"

B4X:
processBA = new BA(this.getApplicationContext(), null, null, "se.iqpd.checkout.plus", "se.iqpd.checkout.plus.main");
processBA.loadHtSubs(this.getClass());

Do you think its possible to use that code in a library, or send that object into the library so it binds to that object?

Something like this...

B4X:
Intent i = new Intent();
i.setClassName( "com.ingenico.pclservice","com.ingenico.pclservice.PclService" );
processBA.context.bindService(i, this.mServiceConnection,Context.BIND_AUTO_CREATE) // <----- This is the modification

Do you think this is possible?
 
Top