Java Question Try To Make startapp libraries

hanyelmehy

Active Member
Licensed User
Longtime User
Hi,
i need to creating libraries for (startapp)
according to there document
this code must be written in main class activity:
B4X:
import com.apperhand.device.android.AndroidSDKProvider;
AndroidSDKProvider.initSDK(this);

i make this code but it did not work:BangHead:
B4X:
package any.b4a.hanylib;
import android.app.Activity;
import android.content.Context;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.Events;
import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.DontInheritEvents;
import anywheresoftware.b4a.objects.ViewWrapper;
import com.apperhand.device.android.AndroidSDKProvider;

@ActivityObject
@Author("HanyElmehy")
@ShortName("HanyLib")
@Version(1)

public class HanyLib {
private BA ba;
  public void Initialize(BA ba)
 {
    AndroidSDKProvider.initSDK(ba.activity);
 }
  
  }

When i use in B4A

B4X:
Dim  Me1 As HanyLib
Me1.Initialize

i get this error:
B4X:
** Activity (main) Create, isFirst = true **
main_activity_create (B4A line: 28)
Me1.Initialize
java.lang.Error: Unresolved compilation problem: 
   The method initSDK(Context) in the type AndroidSDKProvider is not applicable for the arguments (BA)

   at any.b4a.hanylib.HanyLib.Initialize(HanyLib.java:44)
   at b4a.example.main._activity_create(main.java:239)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:521)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at b4a.example.main.afterFirstLayout(main.java:85)
   at b4a.example.main.access$100(main.java:16)
   at b4a.example.main$WaitForLayout.run(main.java:72)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:123)
   at android.app.ActivityThread.main(ActivityThread.java:4627)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:521)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
   at dalvik.system.NativeStart.main(Native Method)

any help well be appreciated
Thank you
 

warwound

Expert
Licensed User
Longtime User
Try ba.context instead of ba.activity

Martin.

Sent from my GT-I9300 using Tapatalk 2
 
Top