Last active
June 5, 2020 00:36
-
-
Save chelseatroy/c73af86e009430e6d2219ce571034332 to your computer and use it in GitHub Desktop.
Adding Check for Network
This file contains hidden or 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