Android Question IBM Worklight and B4A communication

jazzzzzzz

Active Member
Licensed User
Longtime User
Am currently doing a project which plays multiple videos in same window,I have completed it with b4a..Now my friends are creating a hybrid application for the same,but that multiple video playback does not works in IBM Worklight...Hybrid platform they use is IBM Worklight..

IBM Worklight have a option to run some Android native code(java),details about how the native and hybrid apps communicate is given in the following pdf

http://public.dhe.ibm.com/software/...klight_API_in_native_Android_applications.pdf

So now I wanna know is it possible with our B4A to communicate with the hybrid(its possible in eclipse).Please read the above PDF,They are adding a .jar file and a properties file to eclipse and calls methods in the jar file...Can some body help me to make me understand if this is possible in B4A?..I know that external jar file can be added to B4A but i think this is some complicated thing..Can sombody help to achieve this...

I think @Erel have some knowledge about worklight as he comes from IBM.....FingersCrossed
 

jazzzzzzz

Active Member
Licensed User
Longtime User
Ok there is an option in worklight to call code in native android(java)

I have tested it and it works...but my b4a code is about 2000 lines so it will be a harder task to compile it in eclipse,,,

So i started by compiling this code in b4a and add it in eclipse..
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Log("a")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Its nothing just show a log message...But this app force closes when i compiled using eclipse(I have added core.jar and b4ashared.jar in eclipse).Can you please tell whats the problem here?

i have attached a pdf about how to add native support within worklight
 

Attachments

  • Module_09_1_-_Android_Development_Combining_Native_and_Web_Pages.pdf
    348 KB · Views: 217
Upvote 0

jazzzzzzz

Active Member
Licensed User
Longtime User
@Erel Ok so I decided to call my b4a created app by intent from worklight...

But here i wanna call a particular activity from my app(my application have 7 activities)..Is that possible? can you suggest some examples?
 
Last edited:
Upvote 0

jazzzzzzz

Active Member
Licensed User
Longtime User
You should set the android:exported attribute with the manifest editor:
B4X:
SetActivityAttribute(activity2, android:exported, true)
You can then send an intent to start this activity. The component name should be <package name>/.<activity (lower case)>


ok i have done a b4a app to call another b4a app and send some data between them...
below code works...

B4X:
    i.Initialize("","")
    i.SetComponent("com.senzit.evidencer/.launchpad")
    i.PutExtra("Settings","this is from example")
    Log("test")
   
  If i.IsInitialized Then
      StartActivity(i)
  End If

I want to call this same apps activity from eclipse can you help-?
 
Upvote 0

jazzzzzzz

Active Member
Licensed User
Longtime User

this is my eclipse code...here my app force closes...logcat say activity not found ...can please check?
B4X:
Intent cmt1 = new Intent();
      cmt1.setComponent(new ComponentName("com.senzit.evidencer","launchpad"));
      cmt1.putExtra("Settings", name);
      startActivity(cmt1);

i changed it to "launchpad.java" too...it also dont works...

Can you please check by calling a activity that is created by B4A and call that activity from eclipse?
 
Upvote 0

jazzzzzzz

Active Member
Licensed User
Longtime User
Any way I figured it out....

B4X:
try {
       
      Intent cmt1 = new Intent(Intent.ACTION_MAIN);
      cmt1.setComponent(new ComponentName("com.senzit.evidencer","com.senzit.evidencer.launchpad"));
     
      cmt1.putExtra("Settings", name);
      startActivity(cmt1);
      }
      catch(android.content.ActivityNotFoundException e)
      {
      Toast.makeText(getApplicationContext(), "Activity not found", Toast.LENGTH_LONG).show();
      }

by this we can call an activity created in b4a app in eclipse...
 
Upvote 0
Top