Created
April 20, 2022 14:20
-
-
Save manniru/bba36b61fb4cff82be1aa48d4a2917d4 to your computer and use it in GitHub Desktop.
Can't create handler inside thread that has not called Looper.prepare()
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
| JAVA | |
| new Handler(Looper.getMainLooper()).post(new Runnable() { | |
| @Override | |
| public void run() { | |
| Toast toast = Toast.makeText(mContext, "Something", Toast.LENGTH_SHORT); | |
| toast.show(); | |
| } | |
| }); | |
| KOTLIN | |
| Handler(Looper.getMainLooper()).post { | |
| Toast.makeText(mContext, "Something", Toast.LENGTH_SHORT).show() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment