java android studio应用程序只是说网络连接错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31050758/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 18:00:06  来源:igfitidea点击:

android studio app just says error in network connection

javaandroid

提问by james

I have created a login and register system, when ever I try to login, register, change password or reset password the app just says "Error In Network Connection".

我创建了一个登录和注册系统,当我尝试登录、注册、更改密码或重置密码时,应用程序只会显示“网络连接错误”。

I am using strong internet connection, could you please advise as I have tried to on WI-FI and 4G, however it still says the same error.

我正在使用强大的互联网连接,您能否在我尝试使用 WI-FI 和 4G 时提供建议,但它仍然显示相同的错误。

Please view the logcat errors

请查看 logcat 错误

06-25 14:23:44.625  16888-16888/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: samsung sensitivity: NULL, cateogry: NULL
06-25 14:23:44.705  16888-16903/? E/SPPClientService﹕ ============PushLog. commonIsShipBuild. stop!
06-25 14:23:44.705  16888-16903/? E/SPPClientService﹕ [PushClientApplication] Push log off : This is Ship build version
06-25 14:23:44.735  16906-16906/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:44.735  16906-16906/? E/Zygote﹕ v2
06-25 14:23:44.755  16906-16906/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: platform sensitivity: NULL, cateogry: NULL
06-25 14:23:44.825  16922-16922/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:44.825  16922-16922/? E/Zygote﹕ v2
06-25 14:23:44.845  16922-16922/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: untrusted sensitivity: NULL, cateogry: NULL
06-25 14:23:44.995  16949-16949/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:44.995  16949-16949/? E/Zygote﹕ v2
06-25 14:23:45.055  16949-16949/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: untrusted sensitivity: NULL, cateogry: NULL
06-25 14:23:45.495  16976-16976/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:45.495  16976-16976/? E/Zygote﹕ v2
06-25 14:23:45.545  16976-16976/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: untrusted sensitivity: NULL, cateogry: NULL
06-25 14:23:45.695  16976-16976/? E/PhotosPlugin﹕ Loading PhotosPlugin
06-25 14:23:46.095  17021-17021/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:46.095  17021-17021/? E/Zygote﹕ v2
06-25 14:23:46.135  17021-17021/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: samsung sensitivity: NULL, cateogry: NULL
06-25 14:23:46.495  17060-17060/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:46.495  17060-17060/? E/Zygote﹕ v2
06-25 14:23:46.535  17060-17060/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: platform sensitivity: NULL, cateogry: NULL
06-25 14:23:46.655    3216-3216/? E/PackageReceiver﹕ this package will be replased, skip this package
06-25 14:23:46.655    3216-3216/? E/PackageReceiver﹕ This package will be replaced = com.brad.visor
06-25 14:24:18.665     930-1106/? E/MotionRecognitionService﹕ handler : SCREEN_ON end
06-25 14:23:46.745  17105-17105/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:46.745  17105-17105/? E/Zygote﹕ v2
06-25 14:23:46.785  17105-17105/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: platform sensitivity: NULL, cateogry: NULL
06-25 14:23:46.915  17124-17124/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:46.915  17124-17124/? E/Zygote﹕ v2
06-25 14:23:46.925      292-292/? E/installd﹕ system dir 0 : /system/app/
06-25 14:23:46.925      292-292/? E/installd﹕ system dir 1 : /system/priv-app/
06-25 14:23:46.925      292-292/? E/installd﹕ system dir 2 : /vendor/app/
06-25 14:23:46.925      292-292/? E/installd﹕ system dir 3 : /oem/app/
06-25 14:23:46.955  17124-17124/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: platform sensitivity: NULL, cateogry: NULL
06-25 14:23:47.115  17148-17148/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:47.115  17148-17148/? E/Zygote﹕ v2
06-25 14:23:47.155  17148-17148/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: untrusted sensitivity: NULL, cateogry: NULL
06-25 14:23:47.385  16669-17170/? E/FilterInstaller﹕ There is no requred permission
06-25 14:23:47.465      281-281/? E/SMD﹕ DCD ON
06-25 14:23:47.515  17183-17183/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:47.515  17183-17183/? E/Zygote﹕ v2
06-25 14:23:47.535  17183-17183/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: platform sensitivity: NULL, cateogry: NULL
06-25 14:23:47.545  17199-17199/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:47.545  17199-17199/? E/Zygote﹕ v2
06-25 14:23:47.565  17199-17199/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: untrusted sensitivity: NULL, cateogry: NULL
06-25 14:23:47.815  17223-17223/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:47.815  17223-17223/? E/Zygote﹕ v2
06-25 14:23:47.855  17223-17223/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: samsung sensitivity: NULL, cateogry: NULL
06-25 14:23:48.065  17249-17249/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:48.065  17249-17249/? E/Zygote﹕ v2
06-25 14:23:48.115  17249-17249/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
06-25 14:23:48.205    3216-3216/? E/PackageReceiver﹕ this package will be replased, skip this package
06-25 14:23:48.205    3216-3216/? E/PackageReceiver﹕ This package will be replaced = com.brad.visor
06-25 14:23:48.475    1700-1700/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid parameter app
06-25 14:23:48.475    1700-1700/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
06-25 14:23:48.525  17270-17270/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:23:48.525  17270-17270/? E/Zygote﹕ v2
06-25 14:23:48.555  17270-17270/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: untrusted sensitivity: NULL, cateogry: NULL
06-25 14:23:49.035  17270-17270/? E/SysUtils﹕ ApplicationContext is null in ApplicationStatus
06-25 14:23:49.225  17270-17328/? E/File﹕ fail readDirectory() errno=2
06-25 14:23:49.325    1669-7212/? E/MDM﹕ [181] b.run: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}
06-25 14:23:50.465      281-281/? E/SMD﹕ DCD ON
06-25 14:23:53.475      281-281/? E/SMD﹕ DCD ON
06-25 14:23:56.475      281-281/? E/SMD﹕ DCD ON
06-25 14:23:57.315  17021-17102/? E/SQLiteLog﹕ (284) automatic index on LOCAL_DUPS(local_dup_id)
06-25 14:23:57.925  17021-17102/? E/SQLiteLog﹕ (284) automatic index on LOCAL_DUPS(local_dup_id)
06-25 14:23:58.095  17021-17102/? E/SQLiteLog﹕ (284) automatic index on LOCAL_DUPS(local_dup_id)
06-25 14:23:58.155  17021-17102/? E/SQLiteLog﹕ (284) automatic index on LOCAL_DUPS(local_dup_id)
06-25 14:23:59.465      281-281/? E/SMD﹕ DCD ON
06-25 14:24:02.465      281-281/? E/SMD﹕ DCD ON
06-25 14:24:02.605     930-1128/? E/WifiStateMachine﹕ WifiStateMachine CMD_START_SCAN source 10014 txSuccessRate=94.24 rxSuccessRate=74.75 targetRoamBSSID=c4:04:15:c1:13:70 RSSI=-40
06-25 14:24:02.615     930-1128/? E/WifiStateMachine﹕ [1,435,238,642,625 ms] noteScanStartWorkSource{10014} uid 10014
06-25 14:24:05.475      281-281/? E/SMD﹕ DCD ON
06-25 14:24:06.525     930-1128/? E/WifiStateMachine﹕ [1,435,238,646,538 ms] noteScanEnd WorkSource{10014}
06-25 14:24:06.545     930-1128/? E/WifiStateMachine﹕ wifi setScanResults statecom.android.server.wifi.WifiStateMachine$ConnectedState@550587e sup_state=COMPLETED debouncing=false
06-25 14:24:06.745      930-930/? E/LocSvc_flp﹕ I/===> int flp_inject_location(FlpLocation*) line 222
06-25 14:24:06.745     930-1419/? E/LocSvc_ApiV02﹕ I/<--- void globalRespCb(locClientHandleType, uint32_t, locClientRespIndUnionType, void*) line 125 QMI_LOC_INJECT_POSITION_REQ_V02
06-25 14:24:08.475      281-281/? E/SMD﹕ DCD ON
06-25 14:24:11.465      281-281/? E/SMD﹕ DCD ON
06-25 14:24:14.475      281-281/? E/SMD﹕ DCD ON
06-25 14:24:17.475      281-281/? E/SMD﹕ DCD ON
06-25 14:24:18.545      251-251/? E/qdexternal﹕ writeHPDOption: file write failed '/sys/devices/virtual/graphics/fb1/hpd'
06-25 14:24:18.675     930-1128/? E/WifiStateMachine﹕ handleScreenStateChanged Exit: true
06-25 14:24:18.695     930-1128/? E/WifiStateMachine﹕ setSuspendOptimizationsNative: 4 false -want true stack:setSuspendOptimizationsNative - access800 - processMessage - processMsg
06-25 14:24:18.695     930-1128/? E/native﹕ do suspend false
06-25 14:24:18.885    1315-1315/? E/daemonapp﹕ [MSC_Daemon]>>> WU:1606 [0:0] [NameNotFoundException] !!
06-25 14:24:18.925    4622-4819/? E/BtGatt.ScanManager﹕ default value of curScanSetting 0 is choosen
06-25 14:24:19.905     930-1816/? E/PersonaManagerService﹕ inState():  stateMachine is null !!
06-25 14:24:20.485      281-281/? E/SMD﹕ DCD ON
06-25 14:24:21.125     930-1423/? E/ClipboardUIManager﹕ Failed to get ClipboardService
06-25 14:24:21.155   2258-17537/? E/SamsungIME﹕ lang.getLanguageCode():en, lang.getCountryCode():GB
06-25 14:24:21.155   2258-17538/? E/SamsungIME﹕ lang.getLanguageCode():en, lang.getCountryCode():GB
06-25 14:24:21.685    2258-2258/? E/SamsungIME﹕ SwiftKey guide popup condition 2 : true false false true true true true true true true
06-25 14:24:22.585     930-1128/? E/WifiStateMachine﹕ [1,435,238,662,601 ms] noteScanEnd no scan source
06-25 14:24:22.595     930-1128/? E/WifiStateMachine﹕ wifi setScanResults statecom.android.server.wifi.WifiStateMachine$ConnectedState@550587e sup_state=COMPLETED debouncing=false
06-25 14:24:23.265   1172-17483/? E/SViewCoverBase﹕ requestDumpUpload : MC is not installed
06-25 14:24:23.295     930-1232/? E/ClipboardUIManager﹕ Failed to get ClipboardService
06-25 14:24:23.325   2258-17571/? E/SamsungIME﹕ lang.getLanguageCode():en, lang.getCountryCode():GB
06-25 14:24:23.415   2258-17582/? E/SamsungIME﹕ lang.getLanguageCode():en, lang.getCountryCode():GB
06-25 14:24:23.475      281-281/? E/SMD﹕ DCD ON
06-25 14:24:23.925    2258-2258/? E/SamsungIME﹕ SwiftKey guide popup condition 2 : true false false true true true true true true true
06-25 14:24:25.475     930-1423/? E/ClipboardUIManager﹕ Failed to get ClipboardService
06-25 14:24:25.485  16752-16752/com.brad.visor E/ViewRootImpl﹕ sendUserActionEvent() mView == null
06-25 14:24:25.775     930-1336/? E/Watchdog﹕ !@Sync 167
06-25 14:24:26.485      281-281/? E/SMD﹕ DCD ON
06-25 14:24:27.355     930-1712/? E/ClipboardUIManager﹕ Failed to get ClipboardService
06-25 14:24:27.615      930-947/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:27.615      930-947/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:27.615      930-947/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:27.615      930-947/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:27.625  17614-17614/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:24:27.625  17614-17614/? E/Zygote﹕ v2
06-25 14:24:27.645  17614-17614/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: platform sensitivity: NULL, cateogry: NULL
06-25 14:24:27.855     930-1077/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:27.855     930-1077/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:27.855     930-1077/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:27.855     930-1077/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:27.865  17632-17632/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:24:27.865  17632-17632/? E/Zygote﹕ v2
06-25 14:24:27.895  17632-17632/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: shared sensitivity: NULL, cateogry: NULL
06-25 14:24:27.975      930-947/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:27.975      930-947/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:27.975      930-947/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:27.975      930-947/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:27.985  17648-17648/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:24:27.985  17648-17648/? E/Zygote﹕ v2
06-25 14:24:28.005  17648-17648/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: platform sensitivity: NULL, cateogry: NULL
06-25 14:24:28.075     930-1423/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:28.075     930-1423/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:28.075     930-1423/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:28.075     930-1423/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:28.085  17664-17664/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:24:28.085  17664-17664/? E/Zygote﹕ v2
06-25 14:24:28.115  17664-17664/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: platform sensitivity: NULL, cateogry: NULL
06-25 14:24:28.765     930-1050/? E/PowerManagerService﹕ handleSandman : startDreaming, but isDreaming false
06-25 14:24:28.905     930-1128/? E/WifiStateMachine﹕ WifiStateMachine CMD_START_SCAN source 10014 txSuccessRate=33.91 rxSuccessRate=24.84 targetRoamBSSID=c4:04:15:c1:13:70 RSSI=-41
06-25 14:24:28.905     930-1128/? E/WifiStateMachine﹕ [1,435,238,668,921 ms] noteScanstart no scan source
06-25 14:24:28.905      930-930/? E/LightSensor﹕ Light old sensor_state 0, new sensor_state : 512 en : 1
06-25 14:24:28.965     930-1106/? E/MotionRecognitionService﹕ handler : SCREEN_OFF end
06-25 14:24:28.965     930-1128/? E/WifiStateMachine﹕ handleScreenStateChanged Exit: false
06-25 14:24:28.975    286-17705/? E/AudioPlayer﹕ >>> setAudioEffect Error mAudioFormat : 1, event : 168430090, value : 151652874
06-25 14:24:28.985     930-1128/? E/WifiStateMachine﹕ setSuspendOptimizationsNative: 4 true -want true stack:setSuspendOptimizationsNative - access800 - processMessage - processMsg
06-25 14:24:28.985     930-1128/? E/WifiStateMachine﹕ setSuspendOptimizationsNative do it 4 true stack:setSuspendOptimizationsNative - access800 - processMessage - processMsg
06-25 14:24:28.985     930-1128/? E/native﹕ do suspend true
06-25 14:24:29.025    286-17709/? E/AudioPlayer﹕ >>> setAudioEffect Error mAudioFormat : 1, event : 4587583, value : 4390976
06-25 14:24:29.075    286-17713/? E/AudioPlayer﹕ >>> setAudioEffect Error mAudioFormat : 1, event : 4587583, value : 4390976
06-25 14:24:29.275     930-1014/? E/LightSensor﹕ RED : 0, GREEN : 0, BLUE : 0, CLEAR : 0, CALCULATED LUX : 0.000000, CCT : 1596.000000, REAL LUX : 0.000000 a_time = 238, gain = 64, ir=0, rp1=1, gp1=0, bp1=0, cp1=0, cpl=3202560
06-25 14:24:29.275     930-1076/? E/LightSensor﹕ Light old sensor_state 512, new sensor_state : 0 en : 0
06-25 14:24:29.475      281-281/? E/SMD﹕ DCD ON
06-25 14:24:29.555      930-930/? E/MotionRecognitionService﹕ mReceiver.onReceive : ACTION_USER_PRESENT  :: UNLOCK SCREEN
06-25 14:24:29.555      930-930/? E/LightSensor﹕ Light old sensor_state 0, new sensor_state : 512 en : 1
06-25 14:24:29.595     930-1581/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:29.595     930-1581/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:29.595     930-1581/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:29.595     930-1581/? E/ActivityManager﹕ checkUser: useridlist=null, currentuser=0
06-25 14:24:29.605  17723-17723/? E/Zygote﹕ MountEmulatedStorage()
06-25 14:24:29.605  17723-17723/? E/Zygote﹕ v2
06-25 14:24:29.655  17723-17723/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
06-25 14:24:29.695    1172-1172/? E/StatusBar﹕ onReceive : Intent.ACTION_SCREEN_OFF
06-25 14:24:29.935     930-1014/? E/LightSensor﹕ RED : 0, GREEN : 0, BLUE : 0, CLEAR : 0, CALCULATED LUX : 0.000000, CCT : 1596.000000, REAL LUX : 0.000000 a_time = 238, gain = 64, ir=0, rp1=1, gp1=0, bp1=0, cp1=0, cpl=3202560
06-25 14:24:29.935     930-1076/? E/LightSensor﹕ Light old sensor_state 512, new sensor_state : 0 en : 0
06-25 14:24:29.995    4622-4819/? E/BtGatt.ScanManager﹕ default value of curScanSetting 0 is choosen
06-25 14:24:30.075  17723-17723/? E/SysUtils﹕ ApplicationContext is null in ApplicationStatus
06-25 14:24:32.475      281-281/? E/SMD﹕ DCD ON
06-25 14:24:32.785     930-1128/? E/WifiStateMachine﹕ [1,435,238,672,797 ms] noteScanEnd WorkSource{10014}
06-25 14:24:32.795     930-1128/? E/WifiStateMachine﹕ wifi setScanResults statecom.android.server.wifi.WifiStateMachine$ConnectedState@550587e sup_state=COMPLETED debouncing=false
06-25 14:24:35.485      281-281/? E/SMD﹕ DCD ON
06-25 14:24:38.485      281-281/? E/SMD﹕ DCD ON
06-25 14:24:41.485      281-281/? E/SMD﹕ DCD ON

manifest file

清单文件

  <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.brad.visor" >


    <application


        android:icon="@mipmap/logo"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Login">
        </activity>
        <activity
            android:name=".Register">
        </activity>
        <activity
            android:name=".Registered">
        </activity>
        <activity
            android:name=".Main">
        </activity>
        <activity
            android:name=".PasswordReset">
        </activity>
        <activity
            android:name=".ChangePassword">
        </activity>

    </application>

    <!-- Allow to connect with internet and to know the current network state-->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


</manifest>

回答by Santosh Kathait

In your manifest file add

在您的清单文件中添加

<uses-permission android:name="android.permission.INTERNET" />

回答by Kerbstomp

I'm not 100% if this is your problem because you did not post your manifest file but I've encountered this problem before and to fix it add the permission to your manifest file.

如果这是你的问题,我不是 100%,因为你没有发布你的清单文件,但我以前遇到过这个问题,并修复它添加到你的清单文件的权限。

More info here: http://developer.android.com/training/basics/network-ops/connecting.html

更多信息:http: //developer.android.com/training/basics/network-ops/connecting.html

回答by Pamuj

  1. check application on different devices
  2. check for connection with following method

    public static boolean isNetworkConnected(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
        return networkInfo != null && networkInfo.isConnected();
    }
    
  1. 检查不同设备上的应用程序
  2. 使用以下方法检查连接

    public static boolean isNetworkConnected(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
        return networkInfo != null && networkInfo.isConnected();
    }
    

回答by Cillín

I had a similar problem. Check that your mobile device is connected to the internet. That was the problem for me. No internet connection on the mobile device.

我有一个类似的问题。检查您的移动设备是否已连接到互联网。这就是我的问题。移动设备上没有互联网连接。