简体   繁体   English

Android-如何检查其他用户是否已连接到互联网?

[英]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? 有没有一种方法可以检查另一个用户(已安装我的应用程序)是否已连接到Internet,即使该用户的手机处于睡眠模式也是如此?

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. uid是一些唯一的用户ID。

I would say implement something like Socket , through which you would be able to instantly get who all users are active and connected. 我想说的是实现Socket东西,通过它您可以立即获得所有活动和连接的用户的身份。 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. 就像早上醒来或手机未处于打ze模式时,大多数应用程序如何进行同步操作一样。

Android operating system manages doze mode and so it decides itself whether the phone is in use or away from use during night time. Android操作系统管理打ze模式,因此它会自行决定手机在夜间使用还是停止使用。 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! 我关于如何实现这一目标的2美分,还有其他方法!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android-检查我应用程序的其他用户是否已连接到互联网的最佳方法是什么? - Android - What is the best method to check whether other user of my app is connected to internet or not? 如何在Android中检查移动网络是否连接到互联网 - How to check if mobile network is connected to the internet or not in android 如何检查Android手机未连接到互联网? - How to check that android phone is not connected to internet? 如何检查android中连接的真实互联网? - how to check the real Internet connected in android? android如何检查wifi已连接但没有互联网连接 - android how to check wifi is connected but no internet connection 如何检查Wifi是否已连接,但Android中无法访问Internet - How to check Wifi is connected, but no Internet access in Android 如何检查Android是否已连接互联网 - How to check whether Android has internet connection 检查用户是否已连接到互联网,如果未提示用户打开Android的数据服务 - Check if the user is connected to the internet and if not prompt the user to turn on data services android 如何检查Android设备是否连接到网络? - How can i check whether an android device is connected to the web? 如何在Android中以编程方式检查WiFi adb是否已连接或断开连接? - How to check programmatically whether WiFi adb is connected or disconnected in android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM