Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close app when internet is not available

I want to close my app when an Internet connection is not available.

I check that, but how can I create an alert, and then close my app?

like image 394
DaSilva Avatar asked Nov 04 '11 00:11

DaSilva


People also ask

Will apps work without internet?

Native mobile apps act as the interface between the user and the users' data and require uninterrupted connectivity. Native mobile apps with offline capability stores both the mobile app's software and its data locally on the mobile device. Offline mobile apps allow the user to run the app, regardless of connectivity.

How do I make an app not access the internet?

In the Android Mobile network settings, tap on Data usage. Next, tap on Network access. Now you see a list of all your installed apps and checkmarks for their access to mobile data and Wi-Fi. To block an app from accessing the internet, uncheck both boxes next to its name.

How do I stop an Android application from closing?

In android, by pressing a back button or home button. So put an event key listener for back & home button and terminate the service.

Can't connect to the internet some info may be outdated or not show?

Restart your device. Open your Settings app and tap Network & internet or Connections. Depending on your device, these options may be different. Turn Wi-Fi off and mobile data on, and check if there's a difference. If not, turn mobile data off and Wi-Fi on and check again.


2 Answers

You shouldn't force close an app as the standard way to terminate an application is to press the home button (or use the multitasking bar)

Don’t Quit Programmatically


Never quit an iOS application programmatically because people tend to interpret this as a crash. However, if external circumstances prevent your application from functioning as intended, you need to tell your users about the situation and explain what they can do about it. Depending on how severe the application malfunction is, you have two choices.

Display an attractive screen that describes the problem and suggests a correction. A screen provides feedback that reassures users that there’s nothing wrong with your application. It puts users in control, letting them decide whether they want to take corrective action and continue using your application or press the Home button and open a different application

If only some of your application's features are not working, display either a screen or an alert when people activate the feature. Display the alert only when people try to access the feature that isn’t functioning.

Source

like image 69
James Webster Avatar answered Oct 03 '22 07:10

James Webster


Your app should never close itself. iOS does not have the concept of quitting an app. You can inform the user that there is no internet connectivity and present a waiting screen or something else that shows them that your app is useless until the internet connection is available, but your app should continue running until the OS decides to shut you down.

like image 36
Variable Length Coder Avatar answered Oct 03 '22 07:10

Variable Length Coder