Hashir Sarwar
Hashir Sarwar

Reputation: 1235

Android - How to check whether other user is connected to internet?

Is there a way to check whether the other user (having my app installed) is connected to internet or not even when the user's phone is at sleep mode?

I want to do something like:

if (uid is connected)
{
    perform certain task;
}

else if (uid is not connected)
{
    show a message;
}

where uid is some unique user id.

Upvotes: 0

Views: 119

Answers (1)

Paresh Mayani
Paresh Mayani

Reputation: 128428

I would say implement something like Socket, through which you would be able to instantly get who all users are active and connected. Like how most of the application does sync operation when you wake up in the morning or when your phone is not in the doze mode.

Android operating system manages doze mode and so it decides itself whether the phone is in use or away from use during night time. During the doze time, only priority and needed processes would continue working, rest of all the processes will be forced to kill, here our app won't run and so socket connectivity will be offline. As soon as it comes out from the doze mode, the socket will be reconnected and that's where you need put some tasks again.

My 2 cents on how we can achieve this, there would be other ways as well!

Upvotes: 1

Related Questions