Skip to content

Instantly share code, notes, and snippets.

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
You can’t perform that action at this time.