Android - Programmatically check internet connection and display dialog if notConnected

后端 未结 14 2521
予麋鹿
予麋鹿 2020-12-15 04:04

I am working on a live project. and when user click on the app. the welcome screen appears(there is a webview on that screen). and if the internet is not connected then the

14条回答
  •  南笙
    南笙 (楼主)
    2020-12-15 04:53

    Internet connection also check either in onCreate() or onResume() method. There is no need to call inside the AsyncTask.

    or You can call before call the AsyncTask execute() method

    if(isOnline)
    {
       MyAsyncTask task=new MyAMyAsyncTask();
       task.execute();
    
    }
    
    else
    {
    // no internet connection
    }
    

提交回复
热议问题