Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Last active June 5, 2020 00:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Adding Check for Network
class LoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
...
signInButton.setOnClickListener { view ->
if (isNetworkConnected()) {
startActivity(Intent(this@LoginActivity, MainActivity::class.java))
} else {
AlertDialog.Builder(this).setTitle("No Internet Connection")
.setMessage("Please check your internet connection and try again")
.setPositiveButton(android.R.string.ok) { _, _ -> }
.setIcon(android.R.drawable.ic_dialog_alert).show()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment