Android Question Searching for KSWEB-Control for B4A

DonManfred

Expert
Licensed User
Longtime User
Hallo,

i´m using KSWEB to have MySQL, PHP, Webserver running on my Device. BUT i don´t want to have all of them running all the time. My goal is to start server(s) when my App is started. The Authors of KSWEB publishes a java-Class which should be included with the activity. See KSWEBControl.java.txt (changd ext to .txt to be able to upload here)

Is someone here able to make a library out of it? I would really appreciate any help in this...
I´m disposed to give a donation for it...


They published a blog about this class here:

KSWEB Control
You can control KSWEB by your application via Android Broadcast messages. Note that this feature is in beta testing at the moment and this is the first version of it. List of commands will be changed and be refined over time.

To apply control commands use this java class in your Android project: KSWEBControl.java
The typical usage is to extend this class by your main activity. Each command requires a tag for tracking of the result of its execution. KSWEB sends an answer with a tag via Broadcast after executing any command. It can be KSWEBControl.RESPOND_OK or KSWEBControl.RESPOND_ERROR.

Here you can see a list of available commands to control KSWEB.

This group of static commands allows you to start/stop components (servers) of KSWEB

public static void ftpStart(Activity activity, String tag);
public static void ftpStop(Activity activity, String tag);

public static void lighttpdStart(Activity activity, String tag);
public static void lighttpdStop(Activity activity, String tag);

public static void nginxStart(Activity activity, String tag);
public static void nginxStop(Activity activity, String tag);

public static void mysqlStart(Activity activity, String tag);
public static void mysqlStop(Activity activity, String tag);

These commands allow to start/close KSWEB. “Finish activity” allows to unload KSWEB from memory without shutting down servers

public static void kswebStart(Activity activity, String tag);
public static void kswebClose(Activity activity, String tag);
public static void kswebFinishActivity(Activity activity, String tag);

To configure servers use these commands

Content of configuration file will be replaced by data from configTxt parameter.

public static void lighttpdSetConfig(Activity activity, String tag, String configTxt);
public static void nginxSetConfig(Activity activity, String tag, String configTxt);
public static void phpSetConfig(Activity activity, String tag, String configTxt);
public static void mysqlSetConfig(Activity activity, String tag, String configTxt);


To control http servers host list you can use these commands

public static void lighttpdAddHost(Activity activity, String tag, String hostname, String port, String rootDir);
public static void lighttpdDeleteHost(Activity activity, String tag, String hostname, String port, String rootDir);


public static void nginxAddHost(Activity activity, String tag, String hostname, String port, String rootDir);
public static void nginxDeleteHost(Activity activity, String tag, String hostname, String port, String rootDir);
 

Attachments

  • KSWEBControl.java.txt
    7.7 KB · Views: 255
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Also, double check the KSWeb app first. Sometimes I was unable to manually turn things on / off. Seemed to me if http server was off, none of others could be enabled.
i´ll check this too this evening... I did test it yesterday a few minutes... But after inserting ks.register i was sure it should work... But it was not
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
@DonManfred Only had a short time so far at work, been very hectic.

I have tweaked a couple of bits, added a bit of logging from the library and added the isRegistered.

I have tested this a good few times now and it seems pretty stable for me. Hopefully it will work for you.

New set of files attached. If you still get no joy, can you get the packageName from the app installed on your device just to make sure it is the same.

If need be I can try to do a video to show you it in action.

Remember that when you return to the server app, the ui doesn't update until you swipe between another tab and back.
 

Attachments

  • KSWebcontrol.zip
    5.2 KB · Views: 208
  • KSWebControllerDemo.zip
    7.2 KB · Views: 183
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
@DonManfredI have tweaked a couple of bits, added a bit of logging from the library and added the isRegistered.

Thank you... I saw the log-output from the registering an unregistering the broadcast.

I have tested this a good few times now and it seems pretty stable for me. Hopefully it will work for you.

Sadly but it does nearly the same as the last one. 2 Lines more in log. register and unregister the broadcast.

New set of files attached.

The lib states a version 1.0. I believe it must be right cause i saw the register and unregister log output

If you still get no joy, can you get the packageName from the app installed on your device just to make sure it is the same.

It must be the same. It´s the app i posted in post #1... In settings you can set a serial and then you have a full-version

ru.kslabs.ksweb
came out in log after using
B4X:
    Dim pm As PackageManager
    Dim packages As List
    packages = pm.GetInstalledPackages
    For i = 0 To packages.Size -1
        Log(packages.Get(i))
    Next
I´ve attached the complete list of packages installed

If need be I can try to do a video to show you it in action.

You don´t need to make a video. I believe you when you say it works for you!

Remember that when you return to the server app, the ui doesn't update until you swipe between another tab and back.

After i read that here yesterday i´ve checked twice to swipe all the time i was in ksweb-app. But sadly still no change :-(
 

Attachments

  • packages.txt
    12.3 KB · Views: 1,289
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Damn, what could this be?

What device are you using? I have tested on a Nexus 7 2013. I will also now try on an HTC Desire Z.


How much is the full version. I only have 3 days left to get this working lol
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Installed ksweb trial on HTC, installed control app, tested, works fine

Do you have another device you could try with the trial?

My Log
B4X:
LogCat connected to: SH0BCRT05610
--------- beginning of /dev/log/system


--------- beginning of /dev/log/main

** Activity (main) Create, isFirst = true **

** Activity (main) Resume **
BroadcastReceiver registered
Response Received

FTPStart
true
** Activity (main) Pause, UserClosed = false **

BroadcastReceiver unregistered

** Activity (main) Resume **

BroadcastReceiver registered

Response Received
FTPStop
true
** Activity (main) Pause, UserClosed = false **

BroadcastReceiver unregistered
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
OK I will test on my galaxy s4, maybe it is one of Samsung's many querks
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
yup, works on S4 too.....
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
I have emailed the makers of KSWeb to see if there is any reason it wouldn't work.

OK, this gets stranger, I thought it may be due to me having trial and you having pro, so I bought the Pro version. Still working with pro version on s4.

Do you have any particular settings set? I just started the app with default then test toggling ftp with my demo app
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
I have an Galaxy Note Tab 10,1 too (GT-5200) . Here it works! And like you wrote. I needed to swipe the tabs to see the status-change

hmmmmm, So, it's something with that setup on the Note 3 then.....

Wow, one license per device, that is tight, lol.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
hmmmmm, So, it's something with that setup on the Note 3 then.....

Wow, one license per device, that is tight, lol.

MAYBE THAT´s the problem!? I´´m running the app on two devices (both belong to one google account) and the tablet was first installed.

but:

>Notice, that your serial key is bound to your Google account.
>In case of use KSWEB for business applications, one license is valid only on one device.

I´m using it as private and the app seems to work on both devices

But actually i did not know what setting it could be. i´ll have a look at this point (checking all my systemsettings) later... i´ve pain in my neck and go to bed now. I should visit the doctor tomorrow cause i have the pain now for 4 days :-/
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User

That doesn't sound too good. I agree, you should go to the doctor and have it checked out.

Keep me up to date

Good luck tomorrow.
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Batted a couple of messages back and forth with the dev, he cannot think of any reason why it would fail to work either...
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…