When No Internet Connection App leads to sleeping Satellite Satellite Screen On some devices

52 Views Asked by At

I am facing a weird behavior. When the Internet connection is off (or on, but no data), when I want to open my app by tapping the launcher icon, my app leads me to a screen, that shows a sleeping satellite and no connection. Thus I can't enter my app without an internet connection and data. This happened when I upgraded the API version to 33. and min 23.

Is there anything to do in the code?

My internet connection check is here:

public static boolean checkConnection(@NonNull Context context) {
    
    ConnectivityManager mConnectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();

    return ( mNetworkInfo != null
             && mNetworkInfo.isAvailable()
             && mNetworkInfo.isConnected()
    );
}

sleeping satellite screen

1

There are 1 best solutions below

0
Rouf Syed On

Go through life cycle scope of android application. It will help you better understand how apps work.

After reading your question, I understood that when you call the app from the background i.e recent apps... irrespective of internet connection, your app is stuck on that no internet screen.

This is happening because, I believe that you've instantiated your api call function in onCreate(). So when the app starts without internet for the first time, there won't be an api call and you will get that no internet connection screen. And when you press home, the app goes to background. Note, it is not entirely closed.

And when you click on the app icon for the second time, it get called from the background... Here, onResume() function is called.