Take the 2-minute tour ×

My first question, (but long time lurker on StackOverflow) so please don't be too scathing.

I am creating an Android App that has the capability of using a web service to update an SQLite database. Of course, this can only happen if the phone has internet connectivity. I understand how to navigate to the phone settings from the App, but I would like to know if the phone is now connected to the internet upon the user returning to the App.

I have considered using the onStart() and onResume() methods, but is there any way to determine where the user 'came from'. A good example would be the Google Maps/Navigation App. If the user is in Google Maps and presses the Navigation icon, it opens the Navigation App/activity and if GPS is not on, a dialog box shows asking the user if he or she wants to be taken to the GPS settings. They can choose OK, turn on GPS and press the back button to return to the Navigation App. If GPS is now on, they can proceed, otherwise the App shows the dialog box again.

This is good, except the user is allowed to continue, in my case, if there is no internet connectivity. But if there is initially no connectivity, and the user goes away and turns it on, and comes back, then I want to call the method to call the service.

I only want the internet check to happen on opening the App, and upon returning from the phone settings. If I use the onStart() method, the check will happen every time the user opens the activity.

So my question is, how do I check that there is internet connectivity only in the onCreate() method AND when the user returns from the phone settings?

Thanks in advance.

share|improve this question
you can use startActivityForResult to know where your user comes back from. –  njzk2 Sep 27 '12 at 7:53
Great, thanks. That's enough to get me started. –  satyrFrost Sep 27 '12 at 8:19
add comment

Your Answer



Browse other questions tagged or ask your own question.