Adding Check for Network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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