Created
August 11, 2017 08:50
-
-
Save kobeumut/208433352a3b666c4f920377fce125d6 to your computer and use it in GitHub Desktop.
This is a common problem, you can not reach the context first and therefore it is null. What you need to do here is that if you use "ActivityName.this" instead of getApplicationContext(), context etc. your problem will be resolved.
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
/* | |
This is a common problem, you can not reach the context first and therefore it is null. | |
What you need to do here is that if you use "ActivityName.this" instead of getApplicationContext(), | |
context etc. your problem will be resolved. | |
*/ | |
//For example Alert Dialog; | |
AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this); //Activity name | |
alertDialog.setMessage("Test Messages"); | |
alertDialog.setPositiveButton("OK", listener); | |
AlertDialog alert = alertDialog.create(); | |
alert.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment