當(dāng)前位置:首頁 > IT技術(shù) > 移動平臺 > 正文

安卓:判斷當(dāng)前使用的是什么網(wǎng)
2021-08-07 16:02:16

public static void network(Context context)
{
   ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
   NetworkInfo info = connectivityManager.getActiveNetworkInfo();
   if (info.getType() == ConnectivityManager.TYPE_ETHERNET)
   {

   }
   else if (info.getType() == ConnectivityManager.TYPE_WIFI)
   {

   }
   else if (info.getType() == ConnectivityManager.TYPE_MOBILE)
   {
      
   }
}

本文摘自 :https://blog.51cto.com/u

開通會員,享受整站包年服務(wù)立即開通 >