Home » Java » java – Not To Display No Internet Alert When It's Connected with WIFI-Exceptionshub

java – Not To Display No Internet Alert When It's Connected with WIFI-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

When I connect my phone with WIFI and tried to open my app. My app did this alert. But, I used this code only to detect No Internet Connection. So, Where is my Mistake in this code?

public static void noInternetAlert(FragmentActivity activity) {
    if(activity==null)
        return;
    try{
        //error connecting
        Alert alert = new Alert();
        alert.DisplayText(activity.getString(R.string.no_internet_error_title), activity.getString(R.string.no_internet_error), activity.getString(R.string.Alert_accept), activity.getString(R.string.Alert_cancel), activity);
        alert.show(activity.getSupportFragmentManager(), activity.getString(R.string.no_internet_error));
    }catch(Exception e){
    }
}
How to&Answers: