Android Question communicate between tablets over LAN, regardless of tablet state?

Dave O

Well-Known Member
Licensed User
Longtime User
Hi all,

I'm designing an app that runs in a classroom - 1 tablet for the teacher, 20 tablets for the students, all connected to a LAN using wifi.

I want to synchronize data between the tablets. Ideally, I want to be able to sync regardless of the state of the student tablets (running the app, not running it, locked, screen off, or sleeping).

Is it possible for the teacher's tablet (under app control) to exchange data with the student tablets in some or all of these states, or do I have to make sure each student tablet is awake and currently running the app?

(I suspect this is best done using services, but just starting my research into that part.)

Any help appreciated. Thanks!
 
Last edited:

JakeBullet70

Well-Known Member
Licensed User
Longtime User
I think you can. Lets see.

1. You would have to write an app that runs at startup.
2. Uses a services that is always listening. (say using UDP, so you can talk to all tablets)
3. Make sure you use the phone lib and call KeepAlive. (this should keep your App running in the background)

That's all from the top my head. I am sure you will get more replies.
 
Upvote 0

Dave O

Well-Known Member
Licensed User
Longtime User
Thanks for this info.

So, if I understand correctly, it seems that it could work like this:
- I install my app on the teacher tablet and the 20 student tablets.
- I connect all tablets to the local wi-fi network (just a local router, most often with no Internet connection).
- I run the app on each tablet at least once initially to get the service to start (and to restart at reboot in future)?
- If the service is configured correctly, it will be able to listen as long as the tablet is turned on. (It could be sleeping, awake and locked, awake and unlocked, running the app, running another app, whatever).
- The teacher runs the app on their tablet, and presses a button to start the test.
- The service on each student tablet receives a messsage from the teacher tablet to start the test. (The actual P2P communication is probably best discussed in a separate thread on discovery, TCP sockets, UDP, etc.).
- After the test, the teacher's app tells the student tablets to go back to sleep (or does it just not send any messages, and the student tablets just sleep based on their own inactivity?)

Anything here that I've got wrong so far?

(BTW, this is for provincial schools in Cambodia. Tablets are *magic* for kids and teachers alike. ;^)

Thanks again!
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I run the app on each tablet at least once initially to get the service to start (and to restart at reboot in future)?
You should set StartAtBooth attribute to true.

The power issue is important. If the devices go to sleep then you will not be able to communicate with them. You can force them to stay running with a partial lock.
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Your steps sound right.
Remember, your APP (the teacher's APP) is a little different then the student APP's
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Interesting.

But I understood almost nothing :)

To understand, I will use (inappropriately) "ServerApp" for the teacher's app and "ClientApp" for the students app.

The ServerApp has no need for any services or to start on boot.
The ClientApp: there will be a listening service (permanently), in any state of the phone? This service may, receiving a given data key, activate a GUI - activity?

What means: "...to acquire a partial lock..."?

Sorry, but my english is understandable same as the Cambodian language, I guess :( :D
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Longtime User
The ServerApp has no need for any services or to start on boot.

true

The ClientApp: there will be a listening service (permanently), in any state of the phone? This service may, receiving a given data key, activate a GUI - activity?

Yes, This service (ClientApp) should receive a UDP broadcast message from the ServerApp and run some code, do something.

What means: "...to acquire a partial lock..."?

Keeps the tablet from going completely asleep. The screen can shut off but your service is still running.
'partial wake locks only affect the CPU. However a partial wake lock continues even if the user presses on the power button'

I think I explained that right...
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You explain very well, the problem is English, for me (the construction of the sentences changes a lot, from English to Italian).

But i know very well "wake up" (damn :D).

However, it is my fault: I have not used any kind of services, then I do not know well how they work.

The fact that a service ("stick"?) can "start" (resume?) an activity (overlapping any other app is in foreground at any given time) was the information that I consider most important.

Many thanks
 
Upvote 0

coslad

Well-Known Member
Licensed User
Longtime User
maybe ot.... but ... apps like viber/whatapp uses the partial lock ?
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Just an idea...

If the tablets are all connected to the internet and not just a private local network, would the Parse library Push Notifications and 'cloud based data storage' be an option?
The Parse client that listens for push notifications is designed to use minimal device resources - it's battery friendly.

Not sure how the client handles the device being in sleep mode but you can research that.

Martin.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Dave wrote: "(just a local router, most often with no Internet connection)".

On the other hand, I remember having taken into account Parse. At first glance, it seemed like the solution for all applications ... say "Whatsup style"?

To me it seemed that Parse would avoid using a web data server, but I found some problems / complications.

I will try to re-read the thread about this topic, hoping you can add further explanation, Martin.

Thanks
 
Upvote 0

Dave O

Well-Known Member
Licensed User
Longtime User
A bit more info on this project:

I'm hoping to have a single app handle all of this, because all the tablets are designed to be peers. A teacher can pick up any tablet, sign in, and start controlling the other tablets (which, for the duration, become "student" tablets). So technically the service would be running on all tablets (including the teacher's tablet), but the teacher tablet would presumably not receive (or could simply ignore) its own "wake up and run the test" broadcast message.

Most of these schools have no Internet connection, no computers, nothing except a set of tablets that they use for educational purposes. (Some don't even have AC power outlets. They get power (when needed) from car batteries that they charge offsite overnight.)

To get the tablets to talk to each other, we're proposing using a cheap WiFi router.

It may even be possible to get a LAN set up without a separate router. The teacher tablet may be able to create its own hotspot that the other tablets can connect to (just like Android phones can currently create a personal hotspot).

Once the test starts, the teacher asks one question at a time (reading off the tablet), and the students are presented (on their respective tablets) with multiple-choice answers. After 10 seconds, the tablets automatically move on to the next question. Repeat for 30 questions.

Basically, the student tablets are slaved to the teacher tablet until the test is over.

Anyone done anything like this?
 
Upvote 0
Top