Java Question Swarm Lib

hanyelmehy

Active Member
Licensed User
Longtime User
i try to make Swarm Lib (check http://swarmconnect.com/)
also check (http://swarmconnect.com/admin/docs/setup)
i make this code :
B4X:
import com.swarmconnect.Swarm;
import com.swarmconnect.SwarmActivity;
import com.swarmconnect.SwarmLeaderboard;

import android.app.Activity;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
//import anywheresoftware.b4a.objects.ViewWrapper;

@Version(1.0f)
@ShortName("SwarmLib")
@ActivityObject
@DependsOn(values={"Swarm"})
@Author("SwarmB4A")


public class swarmlib extends SwarmActivity{
//public class swarmlib extends Activity{
//public class swarmlib{
   
   
    //private BA ba;
   
    public void Initialize(BA ba,int SWARM_APP_ID,String SWARM_APP_KEY)
    {
       Swarm.init(ba.activity, SWARM_APP_ID, SWARM_APP_KEY);
     }
   
    public void IniAmazon(BA ba,int SWARM_APP_ID,String SWARM_APP_KEY)
    {
       Swarm.enableAlternativeMarketCompatability();        
       Swarm.init(ba.activity, SWARM_APP_ID, SWARM_APP_KEY);
     }
     public void ShowDashboard(){
         Swarm.showDashboard();
     }
     public void ShowLogin(){
         Swarm.showLogin();
     }
     public void ShowLeaderboards(){
         Swarm.showLeaderboards();
     }
     public void ShowAchievements(){
         Swarm.showAchievements();
     }
     public void ShowStore(){
         Swarm.showStore();
     }
    
     public void SubmitScore(int LEADERBOARD_ID,float MyScore)
        {
         SwarmLeaderboard.submitScore(LEADERBOARD_ID, MyScore);
        
         }
     public void ShowLeaderboardsID(int LEADERBOARD_ID)
        {
         SwarmLeaderboard.showLeaderboard(LEADERBOARD_ID);
        
         }
     public void SubmitScoreAndShow(int LEADERBOARD_ID,float MyScore)
        {
         SwarmLeaderboard.submitScoreAndShowLeaderboard(LEADERBOARD_ID, MyScore);
        
         }

}

add this to my manifest
B4X:
AddManifestText(
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>)

                
AddApplicationText(<activity android:name="com.swarmconnect.SwarmMainActivity"
            android:theme="@style/HoloTheme"
            android:configChanges="orientation|keyboardHidden"
            android:windowSoftInputMode="stateHidden"
            android:screenOrientation="portrait"
            android:label="Swarm" />)
AddApplicationText(<service android:name="com.swarmconnect.NotificationService" android:process=":swarm" />)

when try to make Initialize i get this error
B4X:
java.lang.NoClassDefFoundError: com.swarmconnect.R$style
    at com.swarmconnect.SwarmMainActivity.onCreate(Unknown Source)
    at android.app.Activity.performCreate(Activity.java:4470)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
    at android.app.ActivityThread.access$600(ActivityThread.java:128)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4517)
    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:993)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
    at dalvik.system.NativeStart.main(Native Method)

any help
 

hanyelmehy

Active Member
Licensed User
Longtime User
Make sure to follow there Alternatives to extending SwarmActivity instructions.

Do you see a folder named res in their SDK?
Make sure to follow there Alternatives to extending SwarmActivity instructions.
is this mean i cannot use Extend SwarmActivity
Do you see a folder named res in their SDK?
yes ,i copy all files in their res (make read only) to my B4A res
 

hanyelmehy

Active Member
Licensed User
Longtime User
Do you plan to use the #Extends attribute? It will work.

Don't copy the res files. Instead use:
B4X:
#AdditionalRes: <path to res folder>, com.swarmconnect
Thank you for your help ,its work now
i have other issue ,when app work its response one time only? (when i click for example on button to show dashboard its work ,when click again nothing happens) ,any idea
 
Top